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); }