@@ -42,6 +42,7 @@ public function getQmStats(LadderHistory $history, $tierId = 1)
4242
4343 $ queuedPlayers = QmQueueEntry::join ('qm_match_players ' , 'qm_match_players.id ' , '= ' , 'qm_queue_entries.qm_match_player_id ' )
4444 ->where ('ladder_history_id ' , $ history ->id )
45+ ->where ('is_observer ' , false )
4546 ->whereNull ('qm_match_id ' )
4647 ->count ();
4748
@@ -69,7 +70,7 @@ public function getQmStats(LadderHistory $history, $tierId = 1)
6970
7071 public function getFactionsPlayedByPlayer ($ player , $ history )
7172 {
72- return Cache::remember ("getFactionsPlayedByPlayer/ $ history ->short / $ player ->id " , 5 * 60 , function () use ($ player , $ history )
73+ return Cache::remember ("getFactionsPlayedByPlayer/ $ history ->short / $ player ->id " , 10 * 60 , function () use ($ player , $ history )
7374 {
7475 $ now = $ history ->starts ;
7576 $ from = $ now ->copy ()->startOfMonth ()->toDateTimeString ();
@@ -176,50 +177,51 @@ private function getFactionResultsForYR($player, $history, $from, $to)
176177
177178 public function getMapWinLossByPlayer ($ player , $ history )
178179 {
179- // return Cache::remember("getMapWinLossByPlayer/$history->short/$player->id", 5, function () use ($player, $history)
180- // {
181- $ now = $ history ->starts ;
182- $ from = $ now ->copy ()->startOfMonth ()->toDateTimeString ();
183- $ to = $ now ->copy ()->endOfMonth ()->toDateTimeString ();
184-
185- $ playerGamesByMaps = $ player ->playerGames ()
186- ->where ("ladder_history_id " , $ history ->id )
187- ->whereBetween ("player_game_reports.created_at " , [$ from , $ to ])
188- ->groupBy ("scen " )
189- ->get ();
190-
191- $ mapResults = [];
192- foreach ($ playerGamesByMaps as $ pg )
180+ // 10 mins cache, this is pretty heavy?
181+ return Cache::remember ("getMapWinLossByPlayer/ $ history ->short / $ player ->id " , 10 * 60 , function () use ($ player , $ history )
193182 {
194- $ mapWins = $ player ->playerGames ()
195- ->where ("ladder_history_id " , $ history ->id )
196- ->whereBetween ("player_game_reports.created_at " , [$ from , $ to ])
197- ->where ("scen " , $ pg ->scen )
198- ->where ("won " , true )
199- ->count ();
200-
201- $ mapLosses = $ player ->playerGames ()
202- ->where ("ladder_history_id " , $ history ->id )
203- ->whereBetween ("player_game_reports.created_at " , [$ from , $ to ])
204- ->where ("scen " , $ pg ->scen )
205- ->where ("won " , false )
206- ->count ();
183+ $ now = $ history ->starts ;
184+ $ from = $ now ->copy ()->startOfMonth ()->toDateTimeString ();
185+ $ to = $ now ->copy ()->endOfMonth ()->toDateTimeString ();
207186
208- $ mapTotal = $ player ->playerGames ()
187+ $ playerGamesByMaps = $ player ->playerGames ()
209188 ->where ("ladder_history_id " , $ history ->id )
210189 ->whereBetween ("player_game_reports.created_at " , [$ from , $ to ])
211- ->where ("scen " , $ pg -> scen )
212- ->count ();
190+ ->groupBy ("scen " )
191+ ->get ();
213192
214- $ mapResults [$ pg ->scen ] = [
215- "map " => $ pg ->game ->map ,
216- "won " => $ mapWins ,
217- "lost " => $ mapLosses ,
218- "total " => $ mapTotal
219- ];
220- }
221- return $ mapResults ;
222- // });
193+ $ mapResults = [];
194+ foreach ($ playerGamesByMaps as $ pg )
195+ {
196+ $ mapWins = $ player ->playerGames ()
197+ ->where ("ladder_history_id " , $ history ->id )
198+ ->whereBetween ("player_game_reports.created_at " , [$ from , $ to ])
199+ ->where ("scen " , $ pg ->scen )
200+ ->where ("won " , true )
201+ ->count ();
202+
203+ $ mapLosses = $ player ->playerGames ()
204+ ->where ("ladder_history_id " , $ history ->id )
205+ ->whereBetween ("player_game_reports.created_at " , [$ from , $ to ])
206+ ->where ("scen " , $ pg ->scen )
207+ ->where ("won " , false )
208+ ->count ();
209+
210+ $ mapTotal = $ player ->playerGames ()
211+ ->where ("ladder_history_id " , $ history ->id )
212+ ->whereBetween ("player_game_reports.created_at " , [$ from , $ to ])
213+ ->where ("scen " , $ pg ->scen )
214+ ->count ();
215+
216+ $ mapResults [$ pg ->scen ] = [
217+ "map " => $ pg ->game ->map ,
218+ "won " => $ mapWins ,
219+ "lost " => $ mapLosses ,
220+ "total " => $ mapTotal
221+ ];
222+ }
223+ return $ mapResults ;
224+ });
223225 }
224226
225227 public function getWinnerOfTheDay (LadderHistory $ history )
0 commit comments