예제 #1
0
 public static function getCollectionTimePlayed()
 {
     foreach ($GLOBALS['data']['gamesCollection'] as $gameId => $gameProperties) {
         if (isset($GLOBALS['data']['arrayTotalPlays'][$gameId])) {
             $gamePlayed = $GLOBALS['data']['arrayTotalPlays'][$gameId]['plays'];
             usort($gamePlayed, 'App\\Lib\\Utility::compareDate');
             $dateTimestamp = end($gamePlayed)['date'];
             $totalPlay = 0;
             foreach ($gamePlayed as $playDetail) {
                 $totalPlay += $playDetail['quantity'];
             }
             $gameLessTimePlayed[] = ['id' => $gameId, 'name' => $gameProperties['name'], 'url' => Utility::urlToGame($gameId), 'totalPlays' => $totalPlay, 'date' => $dateTimestamp, 'dateFormated' => Carbon::createFromTimestamp($dateTimestamp)->formatLocalized('%e %b %Y'), 'since' => Carbon::createFromTimestamp($dateTimestamp)->diffForHumans()];
         } else {
             // Never played this game
             $gameLessTimePlayed[] = ['id' => $gameId, 'name' => $gameProperties['name'], 'url' => Utility::urlToGame($gameId), 'totalPlays' => 0, 'date' => '', 'dateFormated' => '', 'since' => ''];
         }
     }
     usort($gameLessTimePlayed, 'App\\Lib\\Utility::compareDate');
     return $gameLessTimePlayed;
 }
예제 #2
0
 public static function getMostPlayed($numPage = 1)
 {
     $arrayTotalPlays = $GLOBALS['data']['arrayTotalPlays'];
     $numMostPlayed = array_shift($arrayTotalPlays)['nbPlayed'] + 1;
     $arrayMostPlayed = array_slice($GLOBALS['data']['arrayTotalPlays'], self::MOST_PLAYED_SLICE * $numPage - self::MOST_PLAYED_SLICE, self::MOST_PLAYED_SLICE, true);
     $arrayLabels = [];
     $arrayQuantity = [];
     $arrayUrls = [];
     foreach ($arrayMostPlayed as $gameId => $properties) {
         $arrayLabels[] = str_limit($properties['name'], 30, '...');
         $arrayQuantity[] = $properties['nbPlayed'];
         $arrayUrls[$properties['name']] = Utility::urlToGame($gameId);
     }
     return ['labels' => array_values($arrayLabels), 'serie1' => array_values($arrayQuantity), 'scaleMax' => $numMostPlayed, 'urls' => $arrayUrls];
 }