fix: caching the leaderboard

This commit is contained in:
Paul Couture 2023-12-17 23:22:54 -06:00
parent 3e3e76773c
commit 23e551374a

View File

@ -100,6 +100,7 @@ private function numberFormatPrecision($number, $precision = 2, $separator = '.'
} }
private function leaderboardTwelveMonths() { private function leaderboardTwelveMonths() {
$leaderboard = cache()->remember('leaderboardTwelveMonths', 30, function() {
$endDate = now()->endOfDay()->subYear()->format('Y-m-d'); $endDate = now()->endOfDay()->subYear()->format('Y-m-d');
$leaderboard = DB::table('episodes') $leaderboard = DB::table('episodes')
->join('artworks', 'artworks.id', '=', 'episodes.artwork_id') ->join('artworks', 'artworks.id', '=', 'episodes.artwork_id')
@ -117,6 +118,8 @@ private function leaderboardTwelveMonths() {
->get(); ->get();
$leaderboard = $this->addArtistModelToLeaderboard($leaderboard); $leaderboard = $this->addArtistModelToLeaderboard($leaderboard);
return $leaderboard; return $leaderboard;
});
return $leaderboard;
} }
private function addArtistModelToLeaderboard($leaderboard) { private function addArtistModelToLeaderboard($leaderboard) {