[BUG] Fetching User Playlists with Paginated Method doubles Results
Closed this issue · 6 comments
So, I have tried playlists_paginated() to speed up the process of getting paginated results. Despite I only have 30 playlists, unfortunately the method playlists_paginated() return exactly the double amount of playlists, in my case 60. Any idea what is going wrong?
I usually use playlist_and_favorite_playlists() and paginate it myself, which just works fine and only returns the actual 30 results.
I have not noticed this issue but but my guess would be that each worker (two of them in total) returns the same playlists and therefore results in duplicate playlists when they are appended together. But I don't see why this would happen if the offsets used by each worker is not overlapping.
Can you provide an example on how you are using playlists_paginated() ?
That was also my guess and also what debugging showed. But this is not supposed to be.
A brief example while I am on the road:
fav = Favorite(session, session.user.id)
result = fav.playlists_paginated()
Will provide a proof of concept soon. But it will only have some lines of code how to create a session... Rest stays the same.
I can replicate the issue and I have a fix for it. It seems the v2 endpoint does not like fetching items outside the expected bounds, then it will return the same items (default). At least this applies for playlists, not sure about the other getters.
I have added a way to get the total number of items before fetching so we avoid fetching more than necessary. This has the added bonus of making the worker pool behavior more predictable.
Glad you could solve it so fast. Would be happy about a patch release (:
Glad you could solve it so fast. Would be happy about a patch release (:
Will prepare a new release one of the next few days, when I am sure everything is working as intended.