feat: cleanup after move to new production server.
This commit is contained in:
@@ -33,12 +33,21 @@ class PageController extends Controller
|
||||
public function leaderboards(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$current_year = now()->format('Y');
|
||||
$start_year = 2011;
|
||||
$years = [];
|
||||
while($start_year < $current_year) {
|
||||
$years[] = $start_year;
|
||||
$start_year++;
|
||||
}
|
||||
arsort($years);
|
||||
return view('leaderboards.leaderboards', [
|
||||
'user' => $user,
|
||||
'leaderboardAllTime' => $this->leaderboardAllTime(),
|
||||
'leaderboardPastTwelveMonths' => $this->leaderboardTwelveMonths(),
|
||||
'leaderboardRollingSixMonths' => $this->leaderboardRollingSixMonths(),
|
||||
'leaderboardRollingNinetyDays' => $this->leaderboardRollingNinetyDays(),
|
||||
'leaderboardYears' => $years,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -86,13 +95,13 @@ class PageController extends Controller
|
||||
private function getHeaderCounters()
|
||||
{
|
||||
$headerCounters = [];
|
||||
$artworkCountNumber = Cache::remember('artworkCountNumber', 10, function() {
|
||||
return Artwork::all()->count();
|
||||
$artworkCountNumber = Cache::remember('artworkCountNumber', 30, function() {
|
||||
return Artwork::whereNotNull('approved_by')->count();
|
||||
});
|
||||
$artistCountNumber = Cache::remember('artistCountNumber', 10, function() {
|
||||
$artistCountNumber = Cache::remember('artistCountNumber', 30, function() {
|
||||
return Artist::all()->count();
|
||||
});
|
||||
$episodeCountNumber = Cache::remember('episodeCountNumber', 10, function() {
|
||||
$episodeCountNumber = Cache::remember('episodeCountNumber', 30, function() {
|
||||
return Episode::all()->count();
|
||||
});
|
||||
$headerCounters['Artworks'] = $this->shortNumberCount($artworkCountNumber);
|
||||
@@ -123,6 +132,31 @@ class PageController extends Controller
|
||||
return $response;
|
||||
}
|
||||
|
||||
private function leaderboardByYear($year) {
|
||||
$leaderboard = cache()->remember('leaderboardForYear' . $year, 30, function() {
|
||||
$startDate = Carbon::createFromFormat('Y-m-d', $year . '-01-01')->startOfDay()->format('Y-m-d');
|
||||
$endDate = $startDate->copy()->endOfYear()->format('Y-m-d');
|
||||
$leaderboard = DB::table('episodes')
|
||||
->join('artworks', 'artworks.id', '=', 'episodes.artwork_id')
|
||||
->join('artists', 'artists.id', '=', 'artworks.artist_id')
|
||||
->select([
|
||||
DB::raw('artists.id as artistId'),
|
||||
DB::raw('artists.name as artistName'),
|
||||
DB::raw('count(artworks.id) as artworkCount')
|
||||
])
|
||||
->where('episodes.published', 1)
|
||||
->where('episodes.episode_date', '>=', $startDate)
|
||||
->where('episodes.episode_date', '<=', $endDate)
|
||||
->groupBy('artistId')
|
||||
->orderByDesc('artworkCount')
|
||||
->limit(50)
|
||||
->get();
|
||||
$leaderboard = $this->addArtistModelToLeaderboard($leaderboard);
|
||||
return $leaderboard;
|
||||
});
|
||||
return $leaderboard;
|
||||
}
|
||||
|
||||
private function leaderboardTwelveMonths() {
|
||||
$leaderboard = cache()->remember('leaderboardTwelveMonths', 30, function() {
|
||||
$endDate = now()->endOfDay()->subYear()->format('Y-m-d');
|
||||
|
||||
Reference in New Issue
Block a user