fix(anilist): paginate custom lists before fetching metadata - #649
Open
gusario wants to merge 1 commit into
Open
fix(anilist): paginate custom lists before fetching metadata#649gusario wants to merge 1 commit into
gusario wants to merge 1 commit into
Conversation
Contributor
PR Guard
Maintainers may still close PRs that do not match project direction or review capacity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Large AniList custom lists currently request full metadata for every entry before applying local pagination. This can make the GraphQL response too large or cause the request to fail for lists containing hundreds of entries.
This change first fetches lightweight entries containing only the score and AniList media ID, slices the requested page locally, and then fetches full metadata only for that page. Standard AniList status lists are unchanged.
Linked issue
Closes #<648>
Type of change
Why this approach
AniList custom lists are returned through MediaListCollection, so the complete lightweight entry list is still needed to locate the requested custom list and preserve its configured sort order. Fetching only IDs and scores keeps this first response small, even for large lists.
After slicing the requested page, a second query fetches full metadata using id_in. Since AniList does not guarantee that this response follows the input ID order, the metadata is indexed by media ID and then reassembled by iterating over the original page slice. This preserves both the original ordering and each entry's score.
The tradeoff is that an uncached custom-list page now requires two AniList requests instead of one. However, the total payload is substantially smaller, and both requests continue to use the existing rate-limiting logic.
The metadata request is skipped when the requested page is empty.
Testing
Manually tested against a custom AniList containing 810 entries:
page 1 returned 20 items;
page 2 returned 20 items;
both pages reported the same total;
no media IDs overlapped between the two pages;
full metadata was present for returned items.
There are currently no automated tests covering this AniList custom-list pagination path. No automated test was added in this PR; the change was validated with the live integration check described above.
Documentation
Author checklist
CONTRIBUTING.md.AI usage disclosure
AI tools were used to help investigate the AniList pagination behavior, reason about the two-step query approach, and draft the implementation. I reviewed the resulting code and verified it with the backend build, linting, and a live AniList integration check.