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
80cbdc95
Commit
80cbdc95
authored
6 hours ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(fix): do not summon jurors who have already voted
parent
ca945dff
epic/ReportingAndModeration
1 merge request
!100
Epic/reporting and moderation
Pipeline
#61800281
passed with stages
in 5 minutes and 14 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
9 deletions
+27
-9
Repository.php
Core/Reports/Repository.php
+1
-1
Manager.php
Core/Reports/Summons/Manager.php
+26
-8
No files found.
Core/Reports/Repository.php
View file @
80cbdc95
...
...
@@ -198,7 +198,7 @@ class Repository
continue
;
// avoid duplicate reports
}
$jurorGuids
[
$jurorGuid
s
]
=
true
;
$jurorGuids
[
$jurorGuid
]
=
true
;
$decision
=
new
Jury\Decision
();
$decision
...
...
This diff is collapsed.
Click to expand it.
Core/Reports/Summons/Manager.php
View file @
80cbdc95
...
...
@@ -13,6 +13,7 @@ use Minds\Core\Queue\Client;
use
Minds\Core\Queue\Runners\ReportsAppealSummon
;
use
Minds\Core\Reports\Appeals\Appeal
;
use
Minds\Core\Reports\Summons\Delegates
;
use
Minds\Core\Reports\Manager
as
ReportsManager
;
class
Manager
{
...
...
@@ -22,6 +23,9 @@ class Manager
/** @var Repository $repository */
protected
$repository
;
/** @var ReportsManager $reportsManager */
protected
$reportsManager
;
/** @var QueueClient */
protected
$queueClient
;
...
...
@@ -39,12 +43,14 @@ class Manager
public
function
__construct
(
$cohort
=
null
,
$repository
=
null
,
$reportsManager
=
null
,
$queueClient
=
null
,
$socketDelegate
=
null
)
{
$this
->
cohort
=
$cohort
?:
new
Cohort
();
$this
->
repository
=
$repository
?:
new
Repository
();
$this
->
reportsManager
=
$reportsManager
?:
new
ReportsManager
;
$this
->
queueClient
=
$queueClient
?:
Client
::
build
();
$this
->
socketDelegate
=
$socketDelegate
?:
new
Delegates\SocketDelegate
();
}
...
...
@@ -57,21 +63,33 @@ class Manager
*/
public
function
summon
(
Appeal
$appeal
,
$cohort
=
null
)
{
$reportUrn
=
$appeal
->
getReport
()
->
getUrn
();
// Get a fresh report to collect completed jurors
$report
=
$report
=
$this
->
reportsManager
->
getReport
(
$appeal
->
getReport
()
->
getUrn
());
$reportUrn
=
$report
->
getUrn
();
$juryType
=
'appeal_jury'
;
$missing
=
0
;
if
(
!
$cohort
)
{
$
jury
=
iterator_to_array
(
$this
->
repository
->
getList
([
$
summonses
=
iterator_to_array
(
$this
->
repository
->
getList
([
'report_urn'
=>
$reportUrn
,
'jury_type'
=>
$juryType
,
]));
$completedJurorGuids
=
array_map
(
function
(
$decision
)
{
return
$decision
->
getJurorGuid
();
},
array_merge
(
$report
->
getAppealJuryDecisions
(),
$report
->
getInitialJuryDecisions
()));
// Remove the summons of jurors who have already voted
$summonses
=
array_filter
(
$summonses
,
function
(
Summon
$summons
)
use
(
$completedJurorGuids
)
{
return
!
in_array
(
$summons
->
getJurorGuid
(),
$completedJurorGuids
);
});
// Check how many are missing
$notDeclined
=
array_filter
(
$
jury
,
function
(
Summon
$summon
)
{
return
$summon
->
isAccepted
()
||
$summon
->
isAwaiting
();
$notDeclined
=
array_filter
(
$
summonses
,
function
(
Summon
$summons
)
{
return
$summon
s
->
isAccepted
()
||
$summons
->
isAwaiting
();
});
$missing
=
12
-
count
(
$notDeclined
);
...
...
@@ -84,14 +102,14 @@ class Manager
// Reduce jury to juror guids and try to pick up to missing size
$
juryGuids
=
array_map
(
function
(
Summon
$summon
)
{
return
(
string
)
$summon
->
getJurorGuid
();
},
$
jury
);
$
pendingJurorGuids
=
array_map
(
function
(
Summon
$summons
)
{
return
(
string
)
$summon
s
->
getJurorGuid
();
},
$
summonses
);
$cohort
=
$this
->
cohort
->
pick
([
'size'
=>
$missing
,
'for'
=>
$appeal
->
getOwnerGuid
(),
'except'
=>
$
jury
Guids
,
'except'
=>
$
pendingJuror
Guids
,
'active_threshold'
=>
5
*
60
,
]);
}
...
...
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