mirror of
https://github.com/koel/koel
synced 2024-12-01 00:09:17 +00:00
Rename contributing_artist_id to simple artist_id
This commit is contained in:
parent
a123243658
commit
a8bd7ea7c6
12 changed files with 64 additions and 42 deletions
|
@ -36,7 +36,7 @@ class SongController extends Controller
|
|||
$song = Song::updateOrCreate(['id' => Media::getHash($path)], [
|
||||
'path' => $path,
|
||||
'album_id' => $album->id,
|
||||
'contributing_artist_id' => $artist->id,
|
||||
'artist_id' => $artist->id,
|
||||
'title' => trim(array_get($tags, 'title', '')),
|
||||
'length' => array_get($tags, 'duration', 0),
|
||||
'track' => (int) array_get($tags, 'track'),
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class ContributingArtist extends Artist
|
||||
{
|
||||
protected $table = 'artists';
|
||||
}
|
|
@ -264,7 +264,7 @@ class File
|
|||
}
|
||||
|
||||
$info['album_id'] = $album->id;
|
||||
$info['contributing_artist_id'] = $artist->id;
|
||||
$info['artist_id'] = $artist->id;
|
||||
|
||||
// Remove these values from the info array, so that we can just use the array as model's input data.
|
||||
array_forget($info, ['artist', 'albumartist', 'album', 'cover', 'compilation']);
|
||||
|
|
|
@ -15,7 +15,6 @@ use YouTube;
|
|||
* @property string path
|
||||
* @property string title
|
||||
* @property Album album
|
||||
* @property int contributing_artist_id
|
||||
* @property Artist artist
|
||||
* @property string s3_params
|
||||
* @property float length
|
||||
|
@ -46,7 +45,6 @@ class Song extends Model
|
|||
'length' => 'float',
|
||||
'mtime' => 'int',
|
||||
'track' => 'int',
|
||||
'contributing_artist_id' => 'int',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -58,7 +56,7 @@ class Song extends Model
|
|||
|
||||
public function artist()
|
||||
{
|
||||
return $this->belongsTo(ContributingArtist::class, 'contributing_artist_id');
|
||||
return $this->belongsTo(Artist::class);
|
||||
}
|
||||
|
||||
public function album()
|
||||
|
@ -160,7 +158,7 @@ class Song extends Model
|
|||
}
|
||||
|
||||
return [
|
||||
'artists' => Artist::whereIn('id', $updatedSongs->pluck('contributing_artist_id'))->get(),
|
||||
'artists' => Artist::whereIn('id', $updatedSongs->pluck('artist_id'))->get(),
|
||||
'albums' => Album::whereIn('id', $updatedSongs->pluck('album_id'))->get(),
|
||||
'songs' => $updatedSongs,
|
||||
];
|
||||
|
@ -203,7 +201,7 @@ class Song extends Model
|
|||
|
||||
$album = Album::get($artist, $albumName, $isCompilation);
|
||||
|
||||
$this->contributing_artist_id = $artist->id;
|
||||
$this->artist_id = $artist->id;
|
||||
$this->album_id = $album->id;
|
||||
$this->title = $title;
|
||||
$this->lyrics = $lyrics;
|
||||
|
|
|
@ -233,10 +233,10 @@ class Media
|
|||
Album::deleteWhereIDsNotIn($inUseAlbums);
|
||||
|
||||
$inUseArtists = Song::distinct()
|
||||
->select('contributing_artist_id')
|
||||
->groupBy('contributing_artist_id')
|
||||
->select('artist_id')
|
||||
->groupBy('artist_id')
|
||||
->get()
|
||||
->pluck('contributing_artist_id')
|
||||
->pluck('artist_id')
|
||||
->toArray();
|
||||
$inUseArtists[] = Artist::UNKNOWN_ID;
|
||||
$inUseArtists[] = Artist::VARIOUS_ID;
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class RenameContributingArtistId extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('songs', function ($table) {
|
||||
$table->renameColumn('contributing_artist_id', 'artist_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('songs', function ($table) {
|
||||
$table->renameColumn('artist_id', 'contributing_artist_id');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -44,7 +44,7 @@ export const songStore = {
|
|||
song.fmtLength = secondsToHis(song.length)
|
||||
|
||||
const album = albumStore.byId(song.album_id)
|
||||
const artist = artistStore.byId(song.contributing_artist_id)
|
||||
const artist = artistStore.byId(song.artist_id)
|
||||
|
||||
// Manually set these additional properties to be reactive
|
||||
Vue.set(song, 'playCount', song.playCount || 0)
|
||||
|
@ -244,7 +244,7 @@ export const songStore = {
|
|||
originalSong.album.songs = without(originalSong.album.songs, originalSong)
|
||||
}
|
||||
|
||||
if (originalSong.contributing_artist_id !== song.contributing_artist_id) {
|
||||
if (originalSong.artist_id !== song.artist_id) {
|
||||
// artist has been changed. Remove the song from its old artist
|
||||
originalSong.artist.songs = without(originalSong.artist.songs, originalSong)
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ export default {
|
|||
{
|
||||
id: '39189f4545f9d5671fb3dc964f0080a0',
|
||||
album_id: 1193,
|
||||
contributing_artist_id: 3,
|
||||
artist_id: 3,
|
||||
title: 'I Swear',
|
||||
length: 259.92,
|
||||
playCount: 4
|
||||
|
@ -78,7 +78,7 @@ export default {
|
|||
{
|
||||
id: 'a6a550f7d950d2a2520f9bf1a60f025a',
|
||||
album_id: 1194,
|
||||
contributing_artist_id: 3,
|
||||
artist_id: 3,
|
||||
title: 'I can love you like that',
|
||||
length: 262.61,
|
||||
playCount: 2
|
||||
|
@ -86,84 +86,84 @@ export default {
|
|||
{
|
||||
id: 'd86c30fd34f13c1aff8db59b7fc9c610',
|
||||
album_id: 1195,
|
||||
contributing_artist_id: 3,
|
||||
artist_id: 3,
|
||||
title: 'I turn to you',
|
||||
length: 293.04
|
||||
},
|
||||
{
|
||||
id: 'e6d3977f3ffa147801ca5d1fdf6fa55e',
|
||||
album_id: 1217,
|
||||
contributing_artist_id: 4,
|
||||
artist_id: 4,
|
||||
title: 'Like a rolling stone',
|
||||
length: 373.63
|
||||
},
|
||||
{
|
||||
id: 'aa16bbef6a9710eb9a0f41ecc534fad5',
|
||||
album_id: 1218,
|
||||
contributing_artist_id: 4,
|
||||
artist_id: 4,
|
||||
title: "Knockin' on heaven's door",
|
||||
length: 151.9
|
||||
},
|
||||
{
|
||||
id: 'cb7edeac1f097143e65b1b2cde102482',
|
||||
album_id: 1219,
|
||||
contributing_artist_id: 4,
|
||||
artist_id: 4,
|
||||
title: "The times they are a-changin'",
|
||||
length: 196
|
||||
},
|
||||
{
|
||||
id: '0ba9fb128427b32683b9eb9140912a70',
|
||||
album_id: 1268,
|
||||
contributing_artist_id: 5,
|
||||
artist_id: 5,
|
||||
title: 'No bravery',
|
||||
length: 243.12
|
||||
},
|
||||
{
|
||||
id: '123fd1ad32240ecab28a4e86ed5173',
|
||||
album_id: 1268,
|
||||
contributing_artist_id: 5,
|
||||
artist_id: 5,
|
||||
title: 'So long, Jimmy',
|
||||
length: 265.04
|
||||
},
|
||||
{
|
||||
id: '6a54c674d8b16732f26df73f59c63e21',
|
||||
album_id: 1268,
|
||||
contributing_artist_id: 5,
|
||||
artist_id: 5,
|
||||
title: 'Wisemen',
|
||||
length: 223.14
|
||||
},
|
||||
{
|
||||
id: '6df7d82a9a8701e40d1c291cf14a16bc',
|
||||
album_id: 1268,
|
||||
contributing_artist_id: 5,
|
||||
artist_id: 5,
|
||||
title: 'Goodbye my lover',
|
||||
length: 258.61
|
||||
},
|
||||
{
|
||||
id: '74a2000d343e4587273d3ad14e2fd741',
|
||||
album_id: 1268,
|
||||
contributing_artist_id: 5,
|
||||
artist_id: 5,
|
||||
title: 'High',
|
||||
length: 245.86
|
||||
},
|
||||
{
|
||||
id: '7900ab518f51775fe6cf06092c074ee5',
|
||||
album_id: 1268,
|
||||
contributing_artist_id: 5,
|
||||
artist_id: 5,
|
||||
title: "You're beautiful",
|
||||
length: 213.29
|
||||
},
|
||||
{
|
||||
id: '803910a51f9893347e087af851e38777',
|
||||
album_id: 1268,
|
||||
contributing_artist_id: 5,
|
||||
artist_id: 5,
|
||||
title: 'Cry',
|
||||
length: 246.91
|
||||
},
|
||||
{
|
||||
id: 'd82b0d4d4803ebbcb61000a5b6a868f5',
|
||||
album_id: 1268,
|
||||
contributing_artist_id: 5,
|
||||
artist_id: 5,
|
||||
title: 'Tears and rain',
|
||||
length: 244.45
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import data from '../blobs/data'
|
|||
|
||||
const { songs: allSongs } = data
|
||||
// only get the songs by James Blunt
|
||||
const songs = allSongs.filter(song => song.contributing_artist_id === 5)
|
||||
const songs = allSongs.filter(song => song.artist_id === 5)
|
||||
|
||||
describe('stores/queue', () => {
|
||||
beforeEach(() => {
|
||||
|
|
|
@ -81,7 +81,7 @@ abstract class BrowserKitTestCase extends BaseBrowserKitTestCase
|
|||
foreach ($albums as $album) {
|
||||
factory(Song::class, random_int(7, 15))->create([
|
||||
'album_id' => $album->id,
|
||||
'contributing_artist_id' => $artist->id,
|
||||
'artist_id' => $artist->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class MediaTest extends BrowserKitTestCase
|
|||
|
||||
// Compilation albums, artists and songs must be recognized
|
||||
$song = Song::whereTitle('This song belongs to a compilation')->first();
|
||||
$this->assertNotNull($song->contributing_artist_id);
|
||||
$this->assertNotNull($song->artist_id);
|
||||
$this->assertTrue($song->album->is_compilation);
|
||||
$this->assertEquals(Artist::VARIOUS_ID, $song->album->artist_id);
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ class SongTest extends BrowserKitTestCase
|
|||
|
||||
$this->seeInDatabase('songs', [
|
||||
'id' => $song->id,
|
||||
'contributing_artist_id' => $artist->id,
|
||||
'artist_id' => $artist->id,
|
||||
'album_id' => $compilationAlbum->id,
|
||||
'lyrics' => 'Lorem ipsum dolor sic amet.',
|
||||
'track' => 1,
|
||||
|
@ -211,7 +211,7 @@ class SongTest extends BrowserKitTestCase
|
|||
|
||||
$this->seeInDatabase('songs', [
|
||||
'id' => $song->id,
|
||||
'contributing_artist_id' => $contributingArtist->id,
|
||||
'artist_id' => $contributingArtist->id,
|
||||
'album_id' => $compilationAlbum->id,
|
||||
]);
|
||||
|
||||
|
@ -237,7 +237,7 @@ class SongTest extends BrowserKitTestCase
|
|||
|
||||
$this->seeInDatabase('songs', [
|
||||
'id' => $song->id,
|
||||
'contributing_artist_id' => $contributingArtist->id,
|
||||
'artist_id' => $contributingArtist->id,
|
||||
'album_id' => $compilationAlbum->id,
|
||||
]);
|
||||
|
||||
|
@ -262,7 +262,7 @@ class SongTest extends BrowserKitTestCase
|
|||
|
||||
$this->seeInDatabase('songs', [
|
||||
'id' => $song->id,
|
||||
'contributing_artist_id' => $artist->id,
|
||||
'artist_id' => $artist->id,
|
||||
'album_id' => $album->id,
|
||||
]);
|
||||
|
||||
|
@ -298,7 +298,7 @@ class SongTest extends BrowserKitTestCase
|
|||
$this->assertNotNull($album);
|
||||
$this->seeInDatabase('songs', [
|
||||
'id' => $song->id,
|
||||
'contributing_artist_id' => $artist->id,
|
||||
'artist_id' => $artist->id,
|
||||
'album_id' => $album->id,
|
||||
'lyrics' => 'Thor! Nanananananana Batman.', // haha
|
||||
]);
|
||||
|
|
Loading…
Reference in a new issue