mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 22:47:59 +01:00
Added a "secret" unclassified track type for MLPMA tracks.
This commit is contained in:
parent
2253f51be7
commit
72132d9505
7 changed files with 104 additions and 3 deletions
|
@ -23,6 +23,7 @@ namespace Poniverse\Ponyfm\Commands;
|
||||||
use Poniverse\Ponyfm\Album;
|
use Poniverse\Ponyfm\Album;
|
||||||
use Poniverse\Ponyfm\Image;
|
use Poniverse\Ponyfm\Image;
|
||||||
use Poniverse\Ponyfm\Track;
|
use Poniverse\Ponyfm\Track;
|
||||||
|
use Poniverse\Ponyfm\TrackType;
|
||||||
use Poniverse\Ponyfm\User;
|
use Poniverse\Ponyfm\User;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
@ -65,7 +66,7 @@ class EditTrackCommand extends CommandBase
|
||||||
'license_id' => 'required|exists:licenses,id',
|
'license_id' => 'required|exists:licenses,id',
|
||||||
'genre_id' => 'required|exists:genres,id',
|
'genre_id' => 'required|exists:genres,id',
|
||||||
'cover' => 'image|mimes:png|min_width:350|min_height:350',
|
'cover' => 'image|mimes:png|min_width:350|min_height:350',
|
||||||
'track_type_id' => 'required|exists:track_types,id',
|
'track_type_id' => 'required|exists:track_types,id|not_in:'.TrackType::UNCLASSIFIED_TRACK,
|
||||||
'songs' => 'required_when:track_type,2|exists:songs,id',
|
'songs' => 'required_when:track_type,2|exists:songs,id',
|
||||||
'cover_id' => 'exists:images,id',
|
'cover_id' => 'exists:images,id',
|
||||||
'album_id' => 'exists:albums,id'
|
'album_id' => 'exists:albums,id'
|
||||||
|
@ -121,7 +122,7 @@ class EditTrackCommand extends CommandBase
|
||||||
$track->album_id = null;
|
$track->album_id = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($track->track_type_id == 2) {
|
if ($track->track_type_id == TrackType::OFFICIAL_TRACK_REMIX) {
|
||||||
$track->showSongs()->sync(explode(',', $this->_input['show_song_ids']));
|
$track->showSongs()->sync(explode(',', $this->_input['show_song_ids']));
|
||||||
} else {
|
} else {
|
||||||
$track->showSongs()->sync([]);
|
$track->showSongs()->sync([]);
|
||||||
|
|
54
app/Console/Commands/PublishUnclassifiedMlpmaTracks.php
Normal file
54
app/Console/Commands/PublishUnclassifiedMlpmaTracks.php
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Poniverse\Ponyfm\Console\Commands;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use DB;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Poniverse\Ponyfm\Track;
|
||||||
|
use Poniverse\Ponyfm\TrackType;
|
||||||
|
|
||||||
|
class PublishUnclassifiedMlpmaTracks extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'mlpma:declassify';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'This publishes all unpublished MLPMA tracks as the "unclassified" track type.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$affectedTracks = Track::mlpma()->
|
||||||
|
whereNull('published_at')
|
||||||
|
->update([
|
||||||
|
'track_type_id' => TrackType::UNCLASSIFIED_TRACK,
|
||||||
|
'published_at' => DB::raw('released_at'),
|
||||||
|
'updated_at' => Carbon::now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->info("Updated ${affectedTracks} tracks.");
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,6 +35,7 @@ class Kernel extends ConsoleKernel
|
||||||
\Poniverse\Ponyfm\Console\Commands\RefreshCache::class,
|
\Poniverse\Ponyfm\Console\Commands\RefreshCache::class,
|
||||||
\Poniverse\Ponyfm\Console\Commands\ImportMLPMA::class,
|
\Poniverse\Ponyfm\Console\Commands\ImportMLPMA::class,
|
||||||
\Poniverse\Ponyfm\Console\Commands\ClassifyMLPMA::class,
|
\Poniverse\Ponyfm\Console\Commands\ClassifyMLPMA::class,
|
||||||
|
\Poniverse\Ponyfm\Console\Commands\PublishUnclassifiedMlpmaTracks::class,
|
||||||
\Poniverse\Ponyfm\Console\Commands\RebuildTags::class,
|
\Poniverse\Ponyfm\Console\Commands\RebuildTags::class,
|
||||||
\Poniverse\Ponyfm\Console\Commands\FixYearZeroLogs::class,
|
\Poniverse\Ponyfm\Console\Commands\FixYearZeroLogs::class,
|
||||||
\Poniverse\Ponyfm\Console\Commands\BootstrapLocalEnvironment::class,
|
\Poniverse\Ponyfm\Console\Commands\BootstrapLocalEnvironment::class,
|
||||||
|
|
|
@ -36,7 +36,9 @@ class TaxonomiesController extends ApiControllerBase
|
||||||
'genres' => Genre::select('genres.*',
|
'genres' => Genre::select('genres.*',
|
||||||
DB::raw('(SELECT COUNT(id) FROM tracks WHERE tracks.genre_id = genres.id AND tracks.published_at IS NOT NULL) AS track_count'))->orderBy('name')->get()->toArray(),
|
DB::raw('(SELECT COUNT(id) FROM tracks WHERE tracks.genre_id = genres.id AND tracks.published_at IS NOT NULL) AS track_count'))->orderBy('name')->get()->toArray(),
|
||||||
'track_types' => TrackType::select('track_types.*',
|
'track_types' => TrackType::select('track_types.*',
|
||||||
DB::raw('(SELECT COUNT(id) FROM tracks WHERE tracks.track_type_id = track_types.id AND tracks.published_at IS NOT NULL) AS track_count'))->get()->toArray(),
|
DB::raw('(SELECT COUNT(id) FROM tracks WHERE tracks.track_type_id = track_types.id AND tracks.published_at IS NOT NULL) AS track_count'))
|
||||||
|
->where('id', '!=', TrackType::UNCLASSIFIED_TRACK)
|
||||||
|
->get()->toArray(),
|
||||||
'show_songs' => ShowSong::select('title', 'id', 'slug',
|
'show_songs' => ShowSong::select('title', 'id', 'slug',
|
||||||
DB::raw('(SELECT COUNT(tracks.id) FROM show_song_track INNER JOIN tracks ON tracks.id = show_song_track.track_id WHERE show_song_track.show_song_id = show_songs.id AND tracks.published_at IS NOT NULL) AS track_count'))->get()->toArray()
|
DB::raw('(SELECT COUNT(tracks.id) FROM show_song_track INNER JOIN tracks ON tracks.id = show_song_track.track_id WHERE show_song_track.show_song_id = show_songs.id AND tracks.published_at IS NOT NULL) AS track_count'))->get()->toArray()
|
||||||
], 200);
|
], 200);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
namespace Poniverse\Ponyfm;
|
namespace Poniverse\Ponyfm;
|
||||||
|
|
||||||
|
use Illuminate\Database\Query\Builder;
|
||||||
use Poniverse\Ponyfm\Traits\SlugTrait;
|
use Poniverse\Ponyfm\Traits\SlugTrait;
|
||||||
use Exception;
|
use Exception;
|
||||||
use External;
|
use External;
|
||||||
|
@ -137,6 +138,16 @@ class Track extends Model
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Limits results to MLP Music Archive tracks.
|
||||||
|
*
|
||||||
|
* @param $query
|
||||||
|
*/
|
||||||
|
public function scopeMlpma($query)
|
||||||
|
{
|
||||||
|
$query->join('mlpma_tracks', 'tracks.id', '=', 'mlpma_tracks.track_id');
|
||||||
|
}
|
||||||
|
|
||||||
public static function popular($count, $allowExplicit = false)
|
public static function popular($count, $allowExplicit = false)
|
||||||
{
|
{
|
||||||
$trackIds = Cache::remember('popular_tracks' . $count . '-' . ($allowExplicit ? 'explicit' : 'safe'), 5,
|
$trackIds = Cache::remember('popular_tracks' . $count . '-' . ($allowExplicit ? 'explicit' : 'safe'), 5,
|
||||||
|
|
|
@ -31,4 +31,5 @@ class TrackType extends Model
|
||||||
const FAN_TRACK_REMIX = 3;
|
const FAN_TRACK_REMIX = 3;
|
||||||
const PONIFIED_TRACK = 4;
|
const PONIFIED_TRACK = 4;
|
||||||
const OFFICIAL_AUDIO_REMIX = 5;
|
const OFFICIAL_AUDIO_REMIX = 5;
|
||||||
|
const UNCLASSIFIED_TRACK = 6;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddUnclassifiedTrackType extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
DB::table('track_types')->insert([
|
||||||
|
'id' => 6,
|
||||||
|
'title' => 'Unclassified',
|
||||||
|
'editor_title' => 'an unclassified track'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
DB::table('track_types')->where('id', 6)->delete();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue