Exemplo n.º 1
0
 public function tobuy()
 {
     $arrayRawUserInfos = BGGData::getUserInfos();
     $arrayRawGamesOwned = BGGData::getGamesOwned();
     $arrayRawGamesPreviouslyOwned = BGGData::getGamesPreviouslyOwned();
     $arrayGamesDetails = BGGData::getDetailOwned($arrayRawGamesOwned);
     $arrayRawGamesRated = BGGData::getGamesRated();
     $arrayRawGamesPlays = BGGData::getPlays();
     $arrayGamesHot = BGGData::getHotWithDetails();
     $arrayUserInfos = UserInfos::getUserInformations($arrayRawUserInfos);
     Stats::getRatedRelatedArrays($arrayRawGamesRated);
     Stats::getCollectionArrays($arrayRawGamesOwned);
     Stats::getCollectionArrays($arrayRawGamesPreviouslyOwned, 'gamesPrevOwned');
     Stats::getOwnedRelatedArrays($arrayGamesDetails);
     Stats::getPlaysRelatedArrays($arrayRawGamesPlays);
     $params['userinfo'] = $arrayUserInfos;
     $gamesToBuy = [];
     // High rated
     $highRating = [];
     foreach ($GLOBALS['data']['gamesRated'] as $idGame => $ratedGame) {
         if (!isset($GLOBALS['data']['gamesCollection'][$idGame]) && !isset($GLOBALS['data']['gamesPrevOwned'][$idGame])) {
             $highRating[$idGame] = $ratedGame;
         }
     }
     uasort($highRating, 'App\\Lib\\Utility::compareOrderRating');
     $highRating = array_slice($highRating, 0, 50, true);
     foreach ($highRating as &$game) {
         $game['weight'] = $game['rating'];
         $game['rating'] .= ' / 10';
     }
     Utility::normalizeArray($highRating, 'weight');
     $this->compileGameArray($gamesToBuy, $highRating, 'Bien classé', 1, 'rating');
     // Played frequently
     $playsFrequently = [];
     foreach ($GLOBALS['data']['arrayTotalPlays'] as $idGame => $game) {
         if (!isset($GLOBALS['data']['gamesCollection'][$idGame]) && !isset($GLOBALS['data']['gamesPrevOwned'][$idGame])) {
             $playsFrequently[$idGame] = $game;
         }
     }
     usort($playsFrequently, 'App\\Lib\\Utility::compareOrderNbPlayed');
     $playsFrequently = array_slice($playsFrequently, 0, 50, true);
     foreach ($playsFrequently as &$game) {
         $game['weight'] = $game['nbPlayed'];
         $game['nbPlayed'] .= ' parties';
     }
     Utility::normalizeArray($playsFrequently, 'weight');
     $this->compileGameArray($gamesToBuy, $playsFrequently, 'Joué souvent', 1, 'nbPlayed');
     // Game hot of the same author
     $gameWithDesignerHot = [];
     $mostDesigner = Graphs::getMostDesignerOwned();
     foreach ($arrayGamesHot as $idGame => $game) {
         if (!isset($GLOBALS['data']['gamesCollection'][$idGame]) && !isset($GLOBALS['data']['gamesPrevOwned'][$idGame])) {
             if (isset($game['detail']['boardgamedesigner'])) {
                 foreach ($game['detail']['boardgamedesigner'] as $hotDesigner) {
                     if (isset($mostDesigner[$hotDesigner['id']])) {
                         $gameWithDesignerHot[$idGame] = $game;
                         $gameWithDesignerHot[$idGame]['weight'] = $mostDesigner[$hotDesigner['id']]['nbOwned'];
                         $gameWithDesignerHot[$idGame]['designer'] = $mostDesigner[$hotDesigner['id']]['name'];
                     }
                 }
             }
         }
     }
     Utility::normalizeArray($gameWithDesignerHot, 'weight');
     $this->compileGameArray($gamesToBuy, $gameWithDesignerHot, 'Jeu d\'un auteur apprécié', 1, 'designer');
     usort($gamesToBuy, 'App\\Lib\\Utility::compareOrderWeight');
     $params['games'] = $gamesToBuy;
     return \View::make('rapports_tobuy', $params);
 }
Exemplo n.º 2
0
 public function home()
 {
     $paramsMenu = Page::getMenuParams();
     // Games owned
     $arrayRawGamesOwned = BGGData::getGamesOwned();
     Stats::getCollectionArrays($arrayRawGamesOwned);
     Stats::getOwnedRelatedArrays(BGGData::getDetailOwned($arrayRawGamesOwned));
     unset($arrayRawGamesOwned);
     // Games and expansions owned
     Stats::getAcquisitionRelatedArrays(BGGData::getGamesAndExpansionsOwned());
     // Games played
     Stats::getPlaysRelatedArrays(BGGData::getPlays());
     // Games rated
     Stats::getRatedRelatedArrays(BGGData::getGamesRated());
     // User infos
     $arrayUserInfos = UserInfos::getUserInformations(BGGData::getUserInfos());
     $totalPlayGameCollection = 0;
     $totalGameOwnedNotPlayed = 0;
     foreach ($GLOBALS['data']['gamesCollection'] as $idGame => $game) {
         if (isset($GLOBALS['data']['arrayTotalPlays'][$idGame])) {
             $totalPlayGameCollection += $GLOBALS['data']['arrayTotalPlays'][$idGame]['nbPlayed'];
         } else {
             $totalGameOwnedNotPlayed++;
         }
     }
     $params['userinfo'] = $arrayUserInfos;
     $params['stats']['nbGamesOwned'] = count($GLOBALS['data']['gamesCollection']);
     $params['stats']['nbGamesAndExpansionsOwned'] = $GLOBALS['data']['nbGamesAndExpansionsOwned'];
     $params['stats']['nbPlaysTotal'] = $GLOBALS['data']['countAllPlays'];
     $params['stats']['nbPlaysDifferentGame'] = count($GLOBALS['data']['arrayTotalPlays']);
     $params['stats']['averagePlayByMonth'] = 0;
     $params['stats']['averagePlayDifferentByMonth'] = 0;
     if (count($GLOBALS['data']['arrayPlaysByMonth']) > 0) {
         $params['stats']['averagePlayByMonth'] = round($GLOBALS['data']['countAllPlays'] / count($GLOBALS['data']['arrayPlaysByMonth']));
         $params['stats']['averagePlayDifferentByMonth'] = round(count($GLOBALS['data']['arrayTotalPlays']) / count($GLOBALS['data']['arrayPlaysByMonth']));
     }
     $params['stats']['hindex'] = $GLOBALS['data']['hindex'];
     $params['stats']['averageAcquisitionByMonth'] = '';
     if (SessionManager::ifLoginAsSelf()) {
         if (count($GLOBALS['data']['acquisitionsByMonth']) > 0) {
             $params['stats']['averageAcquisitionByMonth'] = round($GLOBALS['data']['totalWithAcquisitionDate'] / count($GLOBALS['data']['acquisitionsByMonth']));
         }
     }
     $params['stats']['averageValueGames'] = '';
     $params['stats']['totalValueGames'] = '';
     if (SessionManager::ifLoginAsSelf()) {
         if (count($GLOBALS['data']['arrayValuesGames']) > 0) {
             $params['stats']['averageValueGames'] = Utility::displayMoney($GLOBALS['data']['totalGamesValue'] / count($GLOBALS['data']['arrayValuesGames']));
         }
         $params['stats']['totalValueGames'] = Utility::displayMoney($GLOBALS['data']['totalGamesValue']);
     }
     $params['stats']['nbPlayAveragePlayCollectionGame'] = round($totalPlayGameCollection / count($GLOBALS['data']['gamesCollection']), 2);
     $params['stats']['nbPlayAverageByDay'] = 0;
     $params['stats']['nbPlayDifferentAverageByDay'] = 0;
     if (isset($GLOBALS['data']['nbDaysSinceFirstPlay'])) {
         $params['stats']['nbPlayAverageByDay'] = round($GLOBALS['data']['countAllPlays'] / $GLOBALS['data']['nbDaysSinceFirstPlay'], 2);
         $params['stats']['nbPlayDifferentAverageByDay'] = round(count($GLOBALS['data']['arrayTotalPlays']) / $GLOBALS['data']['nbDaysSinceFirstPlay'], 2);
     }
     $params['stats']['nbGameOwnedNotPlayed'] = $totalGameOwnedNotPlayed;
     if (count($GLOBALS['data']['gamesCollection']) > 0) {
         $params['stats']['percentGameOwnedNotPlayed'] = Utility::displayPercent(round($totalGameOwnedNotPlayed / count($GLOBALS['data']['gamesCollection']) * 100, 2));
     }
     $params['graphs']['byMonth'] = Graphs::getPlayByMonth();
     $params['graphs']['byYear'] = Graphs::getPlayByYear();
     $params['graphs']['byDayWeek'] = Graphs::getPlayByDayWeek();
     $params['graphs']['mostPlayed'] = Graphs::getMostPlayed();
     $params['graphs']['nbPlayer'] = Graphs::getNbPlayerCollection();
     $params['graphs']['acquisitionByMonth'] = Graphs::getAcquisitionByMonth();
     $params['graphs']['mostType'] = Graphs::getMostType();
     $params['graphs']['playsByRating'] = Graphs::getPlayByRating();
     $params['graphs']['playsByLength'] = Graphs::getPlayByLength();
     $params['table']['ownedTimePlayed'] = Graphs::getOwnedTimePlayed();
     $params['table']['mostDesigner'] = Graphs::getMostDesignerOwned();
     $params['table']['ownedRentable'] = Graphs::getOwnedRentable();
     $params = array_merge($params, $paramsMenu);
     return \View::make('stats', $params);
 }