Special handling for "Tutorials" genre
authorChristian Weiske <cweiske@cweiske.de>
Sun, 12 Jan 2020 20:22:21 +0000 (21:22 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Sun, 12 Jan 2020 20:22:21 +0000 (21:22 +0100)
bin/import-game-data.php

index e5d62e9b9ae10991d6c1f6f00f7db2aecff98e86..cf6a047640861478b3758f4ac65b92bacd8afef8 100755 (executable)
@@ -124,6 +124,13 @@ foreach ($developers as $developer) {
 writeJson('api/v1/discover-data/discover.json', buildDiscover($games));
 writeJson('api/v1/discover-data/home.json', buildDiscoverHome($games));
 
 writeJson('api/v1/discover-data/discover.json', buildDiscover($games));
 writeJson('api/v1/discover-data/home.json', buildDiscoverHome($games));
 
+//make
+writeJson(
+    'api/v1/discover-data/tutorials.json',
+    buildMakeCategory('Tutorials', filterByGenre($games, 'Tutorials'))
+);
+
+
 
 function buildDiscover(array $games)
 {
 
 function buildDiscover(array $games)
 {
@@ -170,7 +177,7 @@ function buildDiscover(array $games)
         );
     }
 
         );
     }
 
-    $genres = getAllGenres($games);
+    $genres = removeMakeGenres(getAllGenres($games));
     sort($genres);
     addChunkedDiscoverRows($data, $genres, 'Genres');
 
     sort($genres);
     addChunkedDiscoverRows($data, $genres, 'Genres');
 
@@ -226,6 +233,25 @@ function buildDiscoverCategory($name, $games)
     return $data;
 }
 
     return $data;
 }
 
+function buildMakeCategory($name, $games)
+{
+    $data = [
+        'title' => $name,
+        'rows'  => [],
+        'tiles' => [],
+    ];
+
+    usort(
+        $games,
+        function ($gameA, $gameB) {
+            return strcasecmp($gameA->title, $gameB->title);
+        }
+    );
+    addDiscoverRow($data, '', $games);
+
+    return $data;
+}
+
 function buildDiscoverHome(array $games)
 {
     //we do not want anything here for now
 function buildDiscoverHome(array $games)
 {
     //we do not want anything here for now
@@ -748,6 +774,17 @@ function getPromotedProduct($game)
     return null;
 }
 
     return null;
 }
 
+function removeMakeGenres($genres)
+{
+    $filtered = [];
+    foreach ($genres as $genre) {
+        if ($genre != 'Tutorials' && $genre != 'Builds') {
+            $filtered[] = $genre;
+        }
+    }
+    return $filtered;
+}
+
 function writeJson($path, $data)
 {
     global $wwwDir;
 function writeJson($path, $data)
 {
     global $wwwDir;