Hide vimeo videos since they cause ssl errors
[stouyapi.git] / bin / filters.php
index 628936a899e2057499f56a1ad7d5e3a14e0174e7..a10777a03ed65bcec36ed507da65c6dc93a30e2b 100644 (file)
@@ -102,6 +102,29 @@ function filterBestRated($origGames, $limit)
     return array_slice($games, 0, $limit);
 }
 
+function filterMostDownloaded($origGames, $limit)
+{
+    $games = array_values($origGames);
+    usort(
+        $games,
+        function ($gameA, $gameB) {
+            return $gameB->rating->count - $gameA->rating->count;
+        }
+    );
+
+    return array_slice($games, 0, $limit);
+}
+
+function filterRandom($origGames, $limit)
+{
+    $randKeys = array_rand($origGames, $limit);
+    $games = [];
+    foreach ($randKeys as $key) {
+        $games[] = $origGames[$key];
+    }
+    return $games;
+}
+
 function sortByTitle($games)
 {
     usort(