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
134
Issues
134
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
22b46d5f
Commit
22b46d5f
authored
6 hours ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(refactor): move stats from es to cassandra
parent
80cbdc95
epic/ReportingAndModeration
1 merge request
!100
Epic/reporting and moderation
Pipeline
#61804457
passed with stages
in 5 minutes and 34 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
70 deletions
+51
-70
TotalAppealsAggregate.php
Core/Reports/Stats/Aggregates/TotalAppealsAggregate.php
+14
-32
TotalOverturnedAggregate.php
Core/Reports/Stats/Aggregates/TotalOverturnedAggregate.php
+23
-1
TotalReportsAggregate.php
Core/Reports/Stats/Aggregates/TotalReportsAggregate.php
+14
-37
No files found.
Core/Reports/Stats/Aggregates/TotalAppealsAggregate.php
View file @
22b46d5f
...
...
@@ -2,16 +2,17 @@
namespace
Minds\Core\Reports\Stats\Aggregates
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Data\ElasticSearch\Prepared
;
use
Minds\Core\Data\Cassandra\Prepared
;
use
Cassandra\Timestamp
;
class
TotalAppealsAggregate
implements
ModerationStatsAggregateInterface
{
/** @var Client $
es
*/
private
$
es
;
/** @var Client $
cql
*/
private
$
cql
;
public
function
__construct
(
$
es
=
null
)
public
function
__construct
(
$
cql
=
null
)
{
$this
->
es
=
$es
?:
Di
::
_
()
->
get
(
'Database\ElasticSearch
'
);
$this
->
cql
=
$cql
?:
Di
::
_
()
->
get
(
'Database\Cassandra\Cql
'
);
}
/**
...
...
@@ -19,35 +20,16 @@ class TotalAppealsAggregate implements ModerationStatsAggregateInterface
*/
public
function
get
()
:
int
{
$body
=
[
'query'
=>
[
'bool'
=>
[
'must'
=>
[
[
'range'
=>
[
'@appeal_timestamp'
=>
[
'gte'
=>
strtotime
(
'midnight -30 days'
)
*
1000
,
'lte'
=>
time
()
*
1000
,
'format'
=>
'epoch_millis'
,
],
],
],
],
],
],
];
$statement
=
"SELECT count(*) as total FROM moderation_reports_by_state
WHERE state IN ('appealed', 'appeal_jury_decided')
AND timestamp > ?"
;
$values
=
[
new
Timestamp
(
strtotime
(
'-30 days'
,
time
()))
];
$query
=
[
'index'
=>
'minds-moderation'
,
'body'
=>
$body
,
'size'
=>
0
,
];
$prepared
=
new
Prepared\Custom
();
$prepared
->
query
(
$statement
,
$values
);
$result
=
$this
->
cql
->
request
(
$prepared
);
$prepared
=
new
Prepared\Search
();
$prepared
->
query
(
$query
);
$result
=
$this
->
es
->
request
(
$prepared
);
return
$result
[
'hits'
][
'total'
];
return
(
int
)
$result
[
0
][
'total'
]
->
value
();
}
}
This diff is collapsed.
Click to expand it.
Core/Reports/Stats/Aggregates/TotalOverturnedAggregate.php
View file @
22b46d5f
<?php
namespace
Minds\Core\Reports\Stats\Aggregates
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Data\Cassandra\Prepared
;
use
Cassandra\Timestamp
;
class
TotalOverturnedAggregate
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
{
return
0
;
$statement
=
"SELECT count(*) as total FROM moderation_reports_by_state
WHERE state IN ('appeal_jury_decided')
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
);
return
(
int
)
$result
[
0
][
'total'
]
->
value
();
}
}
This diff is collapsed.
Click to expand it.
Core/Reports/Stats/Aggregates/TotalReportsAggregate.php
View file @
22b46d5f
...
...
@@ -2,16 +2,17 @@
namespace
Minds\Core\Reports\Stats\Aggregates
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Data\ElasticSearch\Prepared
;
use
Minds\Core\Data\Cassandra\Prepared
;
use
Cassandra\Timestamp
;
class
TotalReportsAggregate
implements
ModerationStatsAggregateInterface
{
/** @var Client $
es
*/
private
$
es
;
/** @var Client $
cql
*/
private
$
cql
;
public
function
__construct
(
$
es
=
null
)
public
function
__construct
(
$
cql
=
null
)
{
$this
->
es
=
$es
?:
Di
::
_
()
->
get
(
'Database\ElasticSearch
'
);
$this
->
cql
=
$cql
?:
Di
::
_
()
->
get
(
'Database\Cassandra\Cql
'
);
}
/**
...
...
@@ -19,40 +20,16 @@ class TotalReportsAggregate implements ModerationStatsAggregateInterface
*/
public
function
get
()
:
int
{
$body
=
[
'query'
=>
[
'nested'
=>
[
'path'
=>
'reports'
,
'query'
=>
[
'bool'
=>
[
'must'
=>
[
[
'range'
=>
[
'reports.@timestamp'
=>
[
'gte'
=>
strtotime
(
'midnight -30 days'
)
*
1000
,
'lte'
=>
time
()
*
1000
,
'format'
=>
'epoch_millis'
,
],
],
],
],
],
],
],
],
];
$statement
=
"SELECT count(*) as total FROM moderation_reports_by_state
WHERE state IN ('reported', 'initial_jury_decided', 'appealed', 'appeal_jury_decided')
AND timestamp > ?"
;
$values
=
[
new
Timestamp
(
strtotime
(
'-30 days'
,
time
()))
];
$query
=
[
'index'
=>
'minds-moderation'
,
'body'
=>
$body
,
'size'
=>
0
,
];
$prepared
=
new
Prepared\Custom
();
$prepared
->
query
(
$statement
,
$values
);
$result
=
$this
->
cql
->
request
(
$prepared
);
$prepared
=
new
Prepared\Search
();
$prepared
->
query
(
$query
);
$result
=
$this
->
es
->
request
(
$prepared
);
return
$result
[
'hits'
][
'total'
];
return
(
int
)
$result
[
0
][
'total'
]
->
value
();
}
}
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