Commit 8587bc1d authored by xiphon's avatar xiphon

sort proposals by date

parent 036f74cd
...@@ -55,6 +55,14 @@ class UpdateSiteProposals extends Command ...@@ -55,6 +55,14 @@ class UpdateSiteProposals extends Command
\Storage::put('complete.json', $json); \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() private function ideaProposals()
{ {
$group = new stdClass(); $group = new stdClass();
...@@ -78,7 +86,7 @@ class UpdateSiteProposals extends Command ...@@ -78,7 +86,7 @@ class UpdateSiteProposals extends Command
if (basename($filename) != $filename) { if (basename($filename) != $filename) {
$this->error("Skipping MR #$mergeRequest->id '$mergeRequest->title': $filename must be in the root folder"); $this->error("Skipping MR #$mergeRequest->id '$mergeRequest->title': $filename must be in the root folder");
continue; continue;
} }
if (in_array($filename, $ideas)) { if (in_array($filename, $ideas)) {
$this->error("Skipping MR #$mergeRequest->id '$mergeRequest->title': duplicated $filename, another MR #$ideas[$filename]->id"); $this->error("Skipping MR #$mergeRequest->id '$mergeRequest->title': duplicated $filename, another MR #$ideas[$filename]->id");
continue; continue;
...@@ -98,7 +106,7 @@ class UpdateSiteProposals extends Command ...@@ -98,7 +106,7 @@ class UpdateSiteProposals extends Command
$responseProposals[] = $prop; $responseProposals[] = $prop;
} }
$group->proposals = $responseProposals; $group->proposals = $this->sortProposalsByDateDesc($responseProposals);
return $group; return $group;
} }
...@@ -131,7 +139,7 @@ class UpdateSiteProposals extends Command ...@@ -131,7 +139,7 @@ class UpdateSiteProposals extends Command
foreach ($proposals as $proposal) { foreach ($proposals as $proposal) {
$responseProposals[] = $this->formatProposal($proposal); $responseProposals[] = $this->formatProposal($proposal);
} }
$group->proposals = $responseProposals; $group->proposals = $this->sortProposalsByDateDesc($responseProposals);
return $group; 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