Skip to content

Reduce database calls for Playlist#duplicate and Playlist#update_multiple#6835

Draft
masaball wants to merge 2 commits into
developfrom
playlist_performance
Draft

Reduce database calls for Playlist#duplicate and Playlist#update_multiple#6835
masaball wants to merge 2 commits into
developfrom
playlist_performance

Conversation

@masaball
Copy link
Copy Markdown
Contributor

@masaball masaball commented May 6, 2026

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 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?).

masaball added 2 commits May 6, 2026 13:20
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant