Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
125
Issues
125
List
Boards
Labels
Service Desk
Milestones
Merge Requests
28
Merge Requests
28
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
9dc49442
Commit
9dc49442
authored
11 minutes ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): improved stats
parent
eadf4ebd
epic/ReportingAndModeration
1 merge request
!100
Epic/reporting and moderation
Pipeline
#62660983
passed with stages
in 4 minutes and 14 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
1 deletion
+63
-1
TotalActionedAggregate.php
Core/Reports/Stats/Aggregates/TotalActionedAggregate.php
+51
-0
Manager.php
Core/Reports/Stats/Manager.php
+12
-1
No files found.
Core/Reports/Stats/Aggregates/TotalActionedAggregate.php
0 → 100644
View file @
9dc49442
<?php
namespace
Minds\Core\Reports\Stats\Aggregates
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Data\Cassandra\Prepared
;
use
Cassandra\Timestamp
;
class
TotalActionedAggregate
implements
ModerationStatsAggregateInterface
{
/** @var Client $cql */
private
$cql
;
public
function
__construct
(
$cql
=
null
)
{
$this
->
cql
=
$cql
?:
Di
::
_
()
->
get
(
'Database\Cassandra\Cql'
);
}
/**
* @return init
*/
public
function
get
()
:
int
{
$statement
=
"SELECT count(*) as total FROM moderation_reports_by_state
WHERE state IN ('initial_jury_decided', 'appealed')
AND timestamp > ?
AND uphold = true
ALLOW FILTERING
"
;
$values
=
[
new
Timestamp
(
strtotime
(
'-30 days'
,
time
()))
];
$prepared
=
new
Prepared\Custom
();
$prepared
->
query
(
$statement
,
$values
);
$result
=
$this
->
cql
->
request
(
$prepared
);
$initialJuryActioned
=
(
int
)
$result
[
0
][
'total'
]
->
value
();
$statement
=
"SELECT count(*) as total FROM moderation_reports_by_state
WHERE state = 'appeal_jury_decided'
AND timestamp > ?"
;
$values
=
[
new
Timestamp
(
strtotime
(
'-30 days'
,
time
()))
];
$prepared
=
new
Prepared\Custom
();
$prepared
->
query
(
$statement
,
$values
);
$result
=
$this
->
cql
->
request
(
$prepared
);
$appealJuryTotal
=
(
int
)
$result
[
0
][
'total'
]
->
value
();
return
$initialJuryActioned
+
$appealJuryTotal
;
}
}
This diff is collapsed.
Click to expand it.
Core/Reports/Stats/Manager.php
View file @
9dc49442
...
...
@@ -23,6 +23,9 @@ class Manager
/** @var Aggregates\TotalReportsAggregate $totalReportsAggregate */
private
$totalReportsAggregate
;
/** @var Aggregates\TotalActionedAggregate $totalActionedAggregate */
private
$totalActionedAggregate
;
/** @var Aggregates\TotalOverturnedAggregate $totalOverturnedAggregate */
private
$totalOverturnedAggregate
;
...
...
@@ -31,6 +34,7 @@ class Manager
$totalPostsAggregate
=
null
,
$totalAppealsAggregate
=
null
,
$totalReportsAggregate
=
null
,
$totalActionedAggregate
=
null
,
$totalOverturnedAggregate
=
null
)
{
...
...
@@ -38,6 +42,7 @@ class Manager
$this
->
totalPostsAggregate
=
$totalPostsAggregate
?:
new
Aggregates\TotalPostsAggregate
;
$this
->
totalAppealsAggregate
=
$totalAppealsAggregate
?:
new
Aggregates\TotalAppealsAggregate
;
$this
->
totalReportsAggregate
=
$totalReportsAggregate
?:
new
Aggregates\TotalReportsAggregate
;
$this
->
totalActionedAggregate
=
$totalActionedAggregate
?:
new
Aggregates\TotalActionedAggregate
;
$this
->
totalOverturnedAggregate
=
$totalOverturnedAggregate
?:
new
Aggregates\TotalOverturnedAggregate
;
}
...
...
@@ -48,18 +53,24 @@ class Manager
{
$postsCount
=
(
int
)
$this
->
totalPostsAggregate
->
get
();
$reportsCount
=
(
int
)
$this
->
totalReportsAggregate
->
get
();
$actionedCount
=
(
int
)
$this
->
totalActionedAggregate
->
get
();
$appealedCount
=
(
int
)
$this
->
totalAppealsAggregate
->
get
();
$overturnedCount
=
(
int
)
$this
->
totalOverturnedAggregate
->
get
();
$reportsPct
=
(
$reportsCount
/
(
$postsCount
?:
1
))
*
100
;
$appealedPct
=
(
$appealedCount
/
(
$reportsCount
?:
1
))
*
100
;
$actionedPct
=
(
$actionedCount
/
(
$reportsCount
?:
1
))
*
100
;
$appealedPct
=
(
$appealedCount
/
(
$actionedCount
?:
1
))
*
100
;
$upheldPct
=
100
-
((
$overturnedCount
/
(
$appealedCount
?:
1
))
*
100
);
$this
->
stats
=
[
'reportedPct'
=>
round
(
$reportsPct
,
2
),
'reported'
=>
$reportsCount
,
'actioned'
=>
$actionedCount
,
'actionedPct'
=>
round
(
$actionedPct
,
2
),
'appealedPct'
=>
round
(
$appealedPct
,
2
),
'appealed'
=>
$appealedCount
,
'upheldPct'
=>
$upheldPct
,
'overturned'
=>
$overturnedCount
,
];
return
$this
->
stats
;
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment