mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +01:00
Merge pull request #115 from Poniverse/fix_genre_merge
Fixed genre merging
This commit is contained in:
commit
143d405d39
1 changed files with 7 additions and 8 deletions
|
@ -47,10 +47,6 @@ class DeleteGenre extends Job implements ShouldQueue
|
||||||
$this->executingUser = Auth::user();
|
$this->executingUser = Auth::user();
|
||||||
$this->genreToDelete = $genreToDelete;
|
$this->genreToDelete = $genreToDelete;
|
||||||
$this->destinationGenre = $destinationGenre;
|
$this->destinationGenre = $destinationGenre;
|
||||||
|
|
||||||
// The genre is deleted synchronously before the job is executed in
|
|
||||||
// order to prevent race conditions.
|
|
||||||
$this->genreToDelete->delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,14 +63,17 @@ class DeleteGenre extends Job implements ShouldQueue
|
||||||
|
|
||||||
// This is done instead of a single UPDATE query in order to
|
// This is done instead of a single UPDATE query in order to
|
||||||
// generate revision logs for the change.
|
// generate revision logs for the change.
|
||||||
$this->genreToDelete->tracks()->chunk(200, function ($tracks) {
|
$tracks = Track::whereGenreId($this->genreToDelete->id)->get();
|
||||||
foreach ($tracks as $track) {
|
|
||||||
/** @var Track $track */
|
|
||||||
|
|
||||||
|
$this->genreToDelete->delete();
|
||||||
|
$chunks = $tracks->chunk(200);
|
||||||
|
|
||||||
|
foreach ($chunks as $chunk) {
|
||||||
|
foreach ($chunk as $track) {
|
||||||
$track->genre_id = $this->destinationGenre->id;
|
$track->genre_id = $this->destinationGenre->id;
|
||||||
$track->save();
|
$track->save();
|
||||||
$track->updateTags();
|
$track->updateTags();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue