Commit 8587bc1d authored by xiphon's avatar xiphon
Browse files

sort proposals by date

parent 036f74cd
......@@ -55,6 +55,14 @@ class UpdateSiteProposals extends Command
\Storage::put('complete.json', $json);
}
private function sortProposalsByDateDesc($responseProposals)
{
usort($responseProposals, function($a, $b){
return strtotime($a->date) < strtotime($b->date) ? 1 : -1;
});
return $responseProposals;
}
private function ideaProposals()
{
$group = new stdClass();
......@@ -78,7 +86,7 @@ class UpdateSiteProposals extends Command
if (basename($filename) != $filename) {
$this->error("Skipping MR #$mergeRequest->id '$mergeRequest->title': $filename must be in the root folder");
continue;
}
}
if (in_array($filename, $ideas)) {
$this->error("Skipping MR #$mergeRequest->id '$mergeRequest->title': duplicated $filename, another MR #$ideas[$filename]->id");
continue;
......@@ -98,7 +106,7 @@ class UpdateSiteProposals extends Command
$responseProposals[] = $prop;
}
$group->proposals = $responseProposals;
$group->proposals = $this->sortProposalsByDateDesc($responseProposals);
return $group;
}
......@@ -131,7 +139,7 @@ class UpdateSiteProposals extends Command
foreach ($proposals as $proposal) {
$responseProposals[] = $this->formatProposal($proposal);
}
$group->proposals = $responseProposals;
$group->proposals = $this->sortProposalsByDateDesc($responseProposals);
return $group;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment