Skip to content

Commit

Permalink
Sort some daily snapshot metrics data for graphs by total packages
Browse files Browse the repository at this point in the history
  • Loading branch information
turtle0x1 committed Sep 30, 2024
1 parent 4b7fcec commit af988e3
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ public function get(\DateTimeImmutable $date = null)
$output["projectMetrics"] = array_values($output["projectMetrics"]);
$output["packages"] = array_values($output["packages"]);

usort($output["managerMetrics"], [$this, "sortPackages"]);
usort($output["hostMetrics"], [$this, "sortPackages"]);
usort($output["projectMetrics"], [$this, "sortPackages"]);

usort($output["packages"], [$this, "sortInstalls"]);

$output["packages"] = array_slice($output["packages"], 0, 20);
Expand All @@ -118,4 +122,9 @@ private function sortInstalls($a, $b)
{
return $a["totalInstalls"] > $b["totalInstalls"] ? -1 : 1;
}

private function sortPackages($a, $b)
{
return $a["packages"] > $b["packages"] ? -1 : 1;
}
}

0 comments on commit af988e3

Please sign in to comment.