Skip to content

Favorites management API changes#127

Open
darrell-k wants to merge 2 commits intoLMS-Community:masterfrom
darrell-k:favoritesManagement
Open

Favorites management API changes#127
darrell-k wants to merge 2 commits intoLMS-Community:masterfrom
darrell-k:favoritesManagement

Conversation

@darrell-k
Copy link
Copy Markdown
Contributor

Replace favorite/getUserFavorites with favorite/getUserFavoriteIds or favorite/status when retrieving the status of favorites. It's a lot less data.

In QobuzGetTracks and QobuzArtist use favorite/status to return a simple boolean.

In QobuzManageFavorites use favorite/getUserFavoriteIds because although it's more data to return than favorite/status, it avoids having to call the status API 3 times (for albums, tracks and artists).

The new API results are cached for 60 seconds, like favorite/getUserFavorites, so extend the cache management in createFavorite and deleteFavorite.

Please give this a good going over.

…gement

Signed-off-by: darrell-k <darrell@darrell.org.uk>
Signed-off-by: darrell-k <darrell@darrell.org.uk>
@SamInPgh
Copy link
Copy Markdown
Contributor

Running with the changes now. Do you anticipate this having any affect on the OMLI import process? I haven't looked at the code yet but could imagine a possible conflict.

@darrell-k
Copy link
Copy Markdown
Contributor Author

There shouldn't be any effect on OMLI, but worth checking.

Comment on lines +441 to +445
$self->getUserFavorites(sub{}, 'refresh');
$self->getUserFavoriteIds(sub{}, 'refresh');
$self->getUserFavoriteStatus(sub{}, { type => 'album', item_id => $args->{album_ids} }, 'refresh') if $args->{album_ids};
$self->getUserFavoriteStatus(sub{}, { type => 'artist', item_id => $args->{artist_ids} }, 'refresh') if $args->{artist_ids};
$self->getUserFavoriteStatus(sub{}, { type => 'track', item_id => $args->{track_ids} }, 'refresh') if $args->{track_ids};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is doing more work than before. Is it worth it? Wouldn't the first call have all the information the subsequent two would get us?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're just clearing caches here, after an add or delete favourite. Maybe we should do it within the add/delete api routines. At least we would know which of the 3 types to clear in the case of the status cache.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not only wiping caches, you're doing calls to eg. favorite/status, too, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry I meant wipe/recreate cache. We could delay the recreation of the cache entry until it is requested again, so just do the clear at that stage.

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.

3 participants