Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add playlists and playlist items #314

Merged
merged 22 commits into from
Jun 30, 2022
Merged

Add playlists and playlist items #314

merged 22 commits into from
Jun 30, 2022

Conversation

robbevp
Copy link
Member

@robbevp robbevp commented Mar 27, 2022

This PR adds a basic implementation of Playlists and exposes this through the API.

The concept of a Playlist is currently the following:

  • A playlist is a collection of either albums, artists or tracks. All items within one playlist should be of the same type.
    This allows us to create playlist like 'My favorite songs', 'My top 10 albums of 2022', 'All artists playing at festival X'
  • The items in a playlist are ordered (though a user can choose to not use this).
  • A playlist is either personal or shared. A personal playlist can only be updated or destroyed by the user it belongs to, a shared playlist can be updated all the users.
    My primary reasoning for this distinction is for subjective and objective lists. 'Robbe's top 10 ambient albums' would be a personal list. 'All artists playing at Rewire 2022' is an objective list that everyone can add to. Another option for a shared list could be 'Music for our road trip'
  • A playlist has a name and a description. This allows the users to keep the name short 'Rewire 2022' and provide extra info in the description 'All artists playing at Rewire 2022'

Questions

Private playlists?

I was doubting to allow a user to make their personal playlists private. Currently all users can see all playlists, where a private playlist would only be visible to the user the list belongs to. I didn't think I'd ever mark a playlist private, but if there is a need for it, I wouldn't mind it either.

Private playlists are now added

PlaylistItem needed?

We currently store the playlist items in a separate model/table. Mostly so we can use Rails' builtins for associations, and store order as an explicit field.

However, at the moment our only interaction with these items is through the item_ids getter/setter, so we don't necessarily need a separate model / table, but also might store item_ids in a json/jsonb type column on the playlists table. This would also allow us to remove the checks on the playlist's type and the item's item_type

@robbevp robbevp added the enhancement New feature or request label Mar 27, 2022
@robbevp robbevp requested a review from chvp March 27, 2022 15:30
@robbevp robbevp self-assigned this Mar 27, 2022
@robbevp
Copy link
Member Author

robbevp commented Mar 27, 2022

I'm keeping this a draft, since the controller implementation might still change a bit (especially around creating/updating lists), while working on a matching PR in the web release. However, I do think that this is ready to be looked at

No longer a draft, since we have matching PR in web, and all the actions are now working as expected

@robbevp robbevp marked this pull request as ready for review March 28, 2022 19:04
app/policies/playlist_policy.rb Outdated Show resolved Hide resolved
app/models/playlist.rb Outdated Show resolved Hide resolved
app/serializers/playlist_serializer.rb Outdated Show resolved Hide resolved
app/models/artist.rb Outdated Show resolved Hide resolved
app/models/playlist.rb Outdated Show resolved Hide resolved
@chvp
Copy link
Member

chvp commented Jun 4, 2022

(Pushed a rebase since this branch didn't include the flake yet.)

flake.nix Outdated Show resolved Hide resolved
@robbevp
Copy link
Member Author

robbevp commented Jun 19, 2022

Updated the merging strategy of tracks and artists to make sure this works when they are in the same playlist. @chvp Maybe take a short look at the changes

@robbevp robbevp requested a review from chvp June 25, 2022 10:23
@robbevp
Copy link
Member Author

robbevp commented Jun 25, 2022

Sorry - one more change, since the current result of with_item_ids was causing errors in the web interface

app/models/playlist.rb Outdated Show resolved Hide resolved
app/models/playlist.rb Outdated Show resolved Hide resolved
@robbevp robbevp requested a review from chvp June 28, 2022 19:03
@robbevp
Copy link
Member Author

robbevp commented Jun 28, 2022

@chvp my last commit only contains some reformatting - both before and after should pass our rubocop config, but i felt that a multiline lamdba made more sense here. Feel free to drop this commit if you disagree

@chvp chvp merged commit 6cc96dc into main Jun 30, 2022
@chvp chvp deleted the enhc/add-playlists branch June 30, 2022 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants