feat: cleanup after move to new production server.
This commit is contained in:
parent
e10736d51e
commit
bc66edb3ce
111
site/app/Console/Commands/ImportMissingLegacyArtworkCommand.php
Normal file
111
site/app/Console/Commands/ImportMissingLegacyArtworkCommand.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Carbon\Carbon;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use ImageOptimizer;
|
||||
use App\Models\User;
|
||||
use App\Models\Artist;
|
||||
use App\Models\Artwork;
|
||||
use App\Models\Podcast;
|
||||
use App\Models\Episode;
|
||||
|
||||
class ImportMissingLegacyArtworkCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'naart:import-legacy-artwork {legacy_artwork_id}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Used to import a single legacy artwork item that was missed in the migration.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$legacyArtwork = DB::connection('legacy')->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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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');
|
||||
|
3
site/public/pinfo.php
Normal file
3
site/public/pinfo.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
die('nope');
|
||||
phpinfo();
|
@ -28,6 +28,7 @@
|
||||
<li><a data-bs-toggle="tab" href="#rolling-annual">Rolling Annual</a></li>
|
||||
<li><a data-bs-toggle="tab" href="#rolling-six-months">Rolling Six Months</a></li>
|
||||
<li><a data-bs-toggle="tab" href="#rolling-ninety-days">Rolling 90 Days</a></li>
|
||||
{{--<li><a data-bs-toggle="tab" href="#by-year">By Year</a></li>--}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -60,6 +61,26 @@
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
{{--<div class="tab-pane fade" id="by-year">
|
||||
<div class="row">
|
||||
<ul class="nav nav-pills custom-pills mb-4" role="tablist">
|
||||
@foreach ($leaderboardYears as $year)
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link" data-bs-toggle="tab" href="#leaderboard-year-{{ $year }}">{{ $year }}</a>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
<div class="container tab-content">
|
||||
@foreach ($leaderboardYears as $year)
|
||||
<div class="tab-pane fade" id="leaderboard-year-{{ $year }}">
|
||||
<div class="row">
|
||||
<h4>{{ $year }} Leaderboard</h4>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>--}}
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
||||
|
@ -12,6 +12,8 @@
|
||||
<a {!! request()->is(['create-artwork', 'create-artwork/*']) ? 'class="active"' : '' !!} href="/create-artwork">Create</a>
|
||||
</li>
|
||||
@endif
|
||||
<li>
|
||||
<a rel="me" {!! request()->is(['support*']) ? 'class="active"' : '' !!} href="/support-development">History & Support</a>
|
||||
<li>
|
||||
<a {!! request()->is(['leaderboards', 'leaderboards/*']) ? 'class="active"' : '' !!} href="/leaderboards">Leaderboards</a>
|
||||
</li>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div class="single-author profile flex-stretch">
|
||||
<div class="thumb">
|
||||
<img src="{{ $artist->header() }}" alt="{{ $artist->name }}'s Cover Photo" />
|
||||
<a href="/artist/{{ $artist->slug }}"><img src="{{ $artist->header() }}" alt="{{ $artist->name }}'s Cover Photo" /></a>
|
||||
</div>
|
||||
<div class="content">
|
||||
<a href="/artist/{{ $artist->slug }}"><img class="author-thumb avatar_img" src="{{ $artist->avatar() }}"
|
||||
|
Loading…
Reference in New Issue
Block a user