fix: 'upcoming' titles failing to fetch

wasn't returning "Page" from the anilist json response
This commit is contained in:
2025-12-18 08:49:17 -05:00
parent 4c96f58cb0
commit 26ca15d4aa
3 changed files with 14 additions and 8 deletions

View File

@@ -30,7 +30,7 @@ export async function fetchPopularTitlesFromAnilist(
); );
break; break;
case "upcoming": case "upcoming":
data = await stub.nextSeasonPopular(next.season, next.year, limit); data = await stub.nextSeasonPopular(next.season, next.year, page, limit);
break; break;
default: default:
throw new Error(`Unknown category: ${category}`); throw new Error(`Unknown category: ${category}`);

View File

@@ -127,8 +127,7 @@ export class AnilistDurableObject extends DurableObject {
) { ) {
return this.handleCachedRequest( return this.handleCachedRequest(
`popular:${JSON.stringify({ season, seasonYear, nextSeason, nextYear, limit })}`, `popular:${JSON.stringify({ season, seasonYear, nextSeason, nextYear, limit })}`,
async () => { () => {
console.log(nextSeason, nextYear, print(BrowsePopularQuery));
return this.fetchFromAnilist(BrowsePopularQuery, { return this.fetchFromAnilist(BrowsePopularQuery, {
season, season,
seasonYear, seasonYear,
@@ -137,19 +136,25 @@ export class AnilistDurableObject extends DurableObject {
limit, 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( return this.handleCachedRequest(
`next_season:${JSON.stringify({ nextSeason, nextYear, limit })}`, `next_season:${JSON.stringify({ nextSeason, nextYear, page, limit })}`,
async () => { async () => {
return this.fetchFromAnilist(NextSeasonPopularQuery, { return this.fetchFromAnilist(NextSeasonPopularQuery, {
nextSeason, nextSeason,
nextYear, nextYear,
limit, limit,
}); page,
}).then((data) => data?.Page);
}, },
24 * 60 * 60 * 1000, 24 * 60 * 60 * 1000,
); );

View File

@@ -259,8 +259,9 @@ export const NextSeasonPopularQuery = graphql(
$nextSeason: MediaSeason $nextSeason: MediaSeason
$nextYear: Int $nextYear: Int
$limit: Int! $limit: Int!
$page: Int!
) { ) {
Page(page: 1, perPage: $limit) { Page(page: $page, perPage: $limit) {
media( media(
season: $nextSeason season: $nextSeason
seasonYear: $nextYear seasonYear: $nextYear