diff --git a/site/app/Console/Commands/ImportMissingLegacyArtworkCommand.php b/site/app/Console/Commands/ImportMissingLegacyArtworkCommand.php new file mode 100644 index 0000000..55d77be --- /dev/null +++ b/site/app/Console/Commands/ImportMissingLegacyArtworkCommand.php @@ -0,0 +1,111 @@ +table('artworks')->where('id', $this->argument('legacy_artwork_id'))->first(); + $legacyEpisode = DB::connection('legacy')->table('episodes')->where('id', $legacyArtwork->episode_id)->first(); + dump($legacyEpisode); + dump($legacyArtwork); + $user = User::where('legacy_id', $legacyArtwork->user_id)->with('artists')->first(); + $artist = $user->artists->first(); + dump($artist); + $podcast = Podcast::find(1); + $episode = Episode::where('episode_number', $legacyEpisode->episode_number)->first(); + dump($episode); + $date = Carbon::parse($legacyArtwork->created_at); + $basename = $date->format('Y') + . '/' + . $date->format('m') + . '/' + . Str::slug($artist->name) + . '_' + . Str::slug($legacyArtwork->title) + . '_' + . Str::random(8) + . '.jpg'; + $thumbnailName = 'thumbnails/' . $basename; + $artworkName = 'artworks/' . $basename; + $artworkExists = Artwork::where('artist_id', $artist->id) + ->where('episode_id', $episode->id) + ->where('title', $legacyArtwork->title) + ->count(); + $thumbnailExists = false; + $artExists = false; + dump($artworkExists); + dump([$thumbnailName, $artworkName]); + if (Storage::disk('static')->exists($thumbnailName)) { + $this->line('Thumbnail already exists.'); + $thumbnailExists = true; + } + if (Storage::disk('static')->exists($artworkName)) { + $this->line('Artwork already exists.'); + $artExists = true; + } + dump([$thumbnailExists, $artExists]); + if (!$artworkExists) { + $artwork = Artwork::factory()->state([ + 'title' => $legacyArtwork->title, + 'artist_id' => $artist->id, + 'description' => null, + 'overlay_id' => null, + 'podcast_id' => $podcast->id, + 'episode_id' => $episode->id, + 'approved_by' => 4, + 'filename' => $basename, + 'legacy_filename' => $legacyArtwork->path . '/' . $legacyArtwork->filename, + 'legacy_id' => $legacyArtwork->id, + 'created_at' => $legacyArtwork->created_at, + 'updated_at' => $legacyArtwork->created_at, + ])->create(); + $img = Image::make('/var/www/html/naartgen/podcastartgenerator/static' . $artwork->legacy_filename) + ->resize(3000, null, function($constraint) { + $constraint->aspectRatio(); + }) + ->encode('jpg', 100) + ->save(Storage::disk('static')->path('/artworks') . '/' . $artwork->filename); + $thumbImg = Image::make('/var/www/html/naartgen/podcastartgenerator/static' . $artwork->legacy_filename) + ->resize(512, null, function($constraint) { + $constraint->aspectRatio(); + }) + ->encode('jpg', 100) + ->save(Storage::disk('static')->path('/thumbnails') . '/' . $artwork->filename); + ImageOptimizer::optimize(Storage::disk('static')->path('/artworks/' . $artwork->filename)); + ImageOptimizer::optimize(Storage::disk('static')->path('/thumbnails/' . $artwork->filename)); + dump($artwork); + } + } +} diff --git a/site/app/Http/Controllers/PageController.php b/site/app/Http/Controllers/PageController.php index 635e82b..a9a1b41 100644 --- a/site/app/Http/Controllers/PageController.php +++ b/site/app/Http/Controllers/PageController.php @@ -33,12 +33,21 @@ public function landing(Request $request) 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 @@ private function mostRecentEpisodes() 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 @@ private function numberFormatPrecision($number, $precision = 2, $separator = '.' 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'); diff --git a/site/public/pinfo.php b/site/public/pinfo.php new file mode 100644 index 0000000..d91afaa --- /dev/null +++ b/site/public/pinfo.php @@ -0,0 +1,3 @@ +Rolling Annual
  • Rolling Six Months
  • Rolling 90 Days
  • + {{--
  • By Year
  • --}} @@ -60,6 +61,26 @@ @endforeach + {{--
    +
    + +
    +
    + @foreach ($leaderboardYears as $year) +
    +
    +

    {{ $year }} Leaderboard

    +
    +
    + @endforeach +
    +
    --}} @endsection diff --git a/site/resources/views/partials/nav/main.blade.php b/site/resources/views/partials/nav/main.blade.php index ed6e0b2..e79fe7b 100644 --- a/site/resources/views/partials/nav/main.blade.php +++ b/site/resources/views/partials/nav/main.blade.php @@ -12,6 +12,8 @@ is(['create-artwork', 'create-artwork/*']) ? 'class="active"' : '' !!} href="/create-artwork">Create @endif +
  • + is(['support*']) ? 'class="active"' : '' !!} href="/support-development">History & Support
  • is(['leaderboards', 'leaderboards/*']) ? 'class="active"' : '' !!} href="/leaderboards">Leaderboards
  • diff --git a/site/resources/views/profile/partials/single-artist-card.blade.php b/site/resources/views/profile/partials/single-artist-card.blade.php index f6969b6..bd41790 100644 --- a/site/resources/views/profile/partials/single-artist-card.blade.php +++ b/site/resources/views/profile/partials/single-artist-card.blade.php @@ -1,6 +1,6 @@
    - {{ $artist->name }}'s Cover Photo + {{ $artist->name }}'s Cover Photo