diff --git a/src/controllers/popular/category/anilist.ts b/src/controllers/popular/category/anilist.ts index 6e9909e..01296c1 100644 --- a/src/controllers/popular/category/anilist.ts +++ b/src/controllers/popular/category/anilist.ts @@ -30,7 +30,7 @@ export async function fetchPopularTitlesFromAnilist( ); break; case "upcoming": - data = await stub.nextSeasonPopular(next.season, next.year, limit); + data = await stub.nextSeasonPopular(next.season, next.year, page, limit); break; default: throw new Error(`Unknown category: ${category}`); diff --git a/src/libs/anilist/anilist-do.ts b/src/libs/anilist/anilist-do.ts index 4e9e405..a9b2056 100644 --- a/src/libs/anilist/anilist-do.ts +++ b/src/libs/anilist/anilist-do.ts @@ -127,8 +127,7 @@ export class AnilistDurableObject extends DurableObject { ) { return this.handleCachedRequest( `popular:${JSON.stringify({ season, seasonYear, nextSeason, nextYear, limit })}`, - async () => { - console.log(nextSeason, nextYear, print(BrowsePopularQuery)); + () => { return this.fetchFromAnilist(BrowsePopularQuery, { season, seasonYear, @@ -137,19 +136,25 @@ export class AnilistDurableObject extends DurableObject { limit, }); }, - 24 * 60 * 60 * 1000, + DateTime.now().plus({ days: 1 }), ); } - async nextSeasonPopular(nextSeason: any, nextYear: number, limit: number) { + async nextSeasonPopular( + nextSeason: any, + nextYear: number, + page: number, + limit: number, + ) { return this.handleCachedRequest( - `next_season:${JSON.stringify({ nextSeason, nextYear, limit })}`, + `next_season:${JSON.stringify({ nextSeason, nextYear, page, limit })}`, async () => { return this.fetchFromAnilist(NextSeasonPopularQuery, { nextSeason, nextYear, limit, - }); + page, + }).then((data) => data?.Page); }, 24 * 60 * 60 * 1000, ); diff --git a/src/libs/anilist/queries.ts b/src/libs/anilist/queries.ts index 506a1a9..5e279ec 100644 --- a/src/libs/anilist/queries.ts +++ b/src/libs/anilist/queries.ts @@ -259,8 +259,9 @@ export const NextSeasonPopularQuery = graphql( $nextSeason: MediaSeason $nextYear: Int $limit: Int! + $page: Int! ) { - Page(page: 1, perPage: $limit) { + Page(page: $page, perPage: $limit) { media( season: $nextSeason seasonYear: $nextYear