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

Support sorting for the /watchlist endpoint #58

Closed
kevincador opened this issue Apr 5, 2019 · 8 comments
Closed

Support sorting for the /watchlist endpoint #58

kevincador opened this issue Apr 5, 2019 · 8 comments
Labels
Feature Request New feature or request

Comments

@kevincador
Copy link

It would be great if we could ask the /watchlist with a way to sort the result. I'm currently looking to fetch the watchlist page by page but I can't if I want to display the watchlist sorted. I have to either fetch the whole list without paging (I'm not sure it's a good idea for really big watchlists) or fetch everything page by page to be able to sort in-app (but then the user will need to wait until every page are fetched and the sort to happen in-app).

One way to handle this would be by adding X-Sort-By and X-Sort-How to the request. If you don't give them in the request, you could still send them back in the response for people relying on it.

@kevincador kevincador changed the title Support sorting for /watchlist Support sorting for the /watchlist endpoint Apr 5, 2019
@rectifyer
Copy link
Contributor

This isn't easily accomplished since a lot of sorting parameters require a lot of logic to do. That is why the website does sorting client side since the database queries and joins would be too intense.

What sorting options are you specifically trying to apply? I can look into specific use cases and see if anything is possible without being a performance hit. In general though, we return all lists in ranked order since it was a performance issue when we created that API method.

@rectifyer rectifyer added the Feature Request New feature or request label Apr 7, 2019
@kevincador
Copy link
Author

I understand. I don't know the complexity behind them in terms of queries but here would be my :

added: would be super useful, the only one I'm really looking forward to seeing if only one can be achieved - seems pretty easy to cache too
released: would be cool for a watchlist but may be better to have a filter /released (after the first media filter) to only get what has been released sorted by release date - but this idea would make it harder to cache so maybe just sort by release date and we can do the work in app
rank: already ✅

Less useful in my opinion:
title: would help find something you know you have in the watchlist - easy to cache
runtime: would help find something short or long - easy to cache
popularity: not easy to cache
percentage: not easy to cache
votes: not easy to cache

@Kashish-Sharma
Copy link

Any updates on this ?

@rectifyer
Copy link
Contributor

I was able to support sorting by rank (default), added, released, and title. This will only work when also specifying an item type for the watchlist. Docs are updated and the updated methods will be available later today.

@kevincador
Copy link
Author

@rectifyer is this available in prod already? I can't see it in the documentation.

@rectifyer
Copy link
Contributor

Oops, there was a typo that hid the documentation updates. Should be there now.

https://trakt.docs.apiary.io/#reference/sync/get-watchlist/get-watchlist

@kevincador
Copy link
Author

Thanks!

Will it be always ascending when I request it the list to be sort? Or should I always check the X-Applied-Sort-How?

@rectifyer
Copy link
Contributor

You should check that header value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants