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,8 +100,9 @@ private function numberFormatPrecision($number, $precision = 2, $separator = '.'
} }
private function leaderboardTwelveMonths() { private function leaderboardTwelveMonths() {
$endDate = now()->endOfDay()->subYear()->format('Y-m-d'); $leaderboard = cache()->remember('leaderboardTwelveMonths', 30, function() {
$leaderboard = DB::table('episodes') $endDate = now()->endOfDay()->subYear()->format('Y-m-d');
$leaderboard = DB::table('episodes')
->join('artworks', 'artworks.id', '=', 'episodes.artwork_id') ->join('artworks', 'artworks.id', '=', 'episodes.artwork_id')
->join('artists', 'artists.id', '=', 'artworks.artist_id') ->join('artists', 'artists.id', '=', 'artworks.artist_id')
->select([ ->select([
@ -115,7 +116,9 @@ private function leaderboardTwelveMonths() {
->orderByDesc('artworkCount') ->orderByDesc('artworkCount')
->limit(10) ->limit(10)
->get(); ->get();
$leaderboard = $this->addArtistModelToLeaderboard($leaderboard); $leaderboard = $this->addArtistModelToLeaderboard($leaderboard);
return $leaderboard;
});
return $leaderboard; return $leaderboard;
} }