Reduce database calls for Playlist#duplicate and Playlist#update_multiple#6835
Draft
masaball wants to merge 2 commits into
Draft
Reduce database calls for Playlist#duplicate and Playlist#update_multiple#6835masaball wants to merge 2 commits into
masaball wants to merge 2 commits into
Conversation
Related issue: #6024 Major changes: * Remove `.move_to_bottom` calls. 'acts_as_list' default appends newly created items to the end of the list rendering the explicit call redundant. * Refactor `PlaylistItem#duplicate!` to have an optional argument `to_playlist`. Default behavior will assign the item to the currently active playlist. Providing `to_playlist` allows assigning the item to an arbitrary user defined playlist. * Refactor the `Playlist#duplicate` and `Playlist#update_multiple` methods to use the new argument on `PlaylistItem#duplicate!`. This allows us to rely entirely on the logic in `PlaylistItem#duplicate!` and avoid having to reassign and resave items. This should reduce a good bit of the overhead on these methods and avoid deadlocks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue: #6024
Major changes:
Remove
.move_to_bottomcalls. 'acts_as_list' default appends newlycreated items to the end of the list rendering the explicit call
redundant.
Refactor
PlaylistItem#duplicate!to have an optional argumentto_playlist. Default behavior will assign the item to the currentlyactive playlist. Providing
to_playlistallows assigning the item to anarbitrary user defined playlist.
Refactor the
Playlist#duplicateandPlaylist#update_multiplemethods to use the new argument on
PlaylistItem#duplicate!. Thisallows us to rely entirely on the logic in
PlaylistItem#duplicate!andavoid having to reassign and resave items. This should reduce a good bit
of the overhead on these methods and hopefully avoid deadlocks.
This PR also includes a commit to clean up the linting in the playlist controller and playlist controller spec.
Follow-up work: Look at the regular Playlist#update method. There may be improvements that could be made there (might be a good candidate for a retry functionality?).