From 144e08a99c0395aedd110f02064e93996b75e137 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Tue, 8 Apr 2025 23:37:22 +0200 Subject: [PATCH] Fix `with=nextEntry` --- api/src/controllers/profiles/nextup.ts | 5 +++-- api/src/controllers/shows/logic.ts | 6 +----- api/src/models/serie.ts | 1 + 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/api/src/controllers/profiles/nextup.ts b/api/src/controllers/profiles/nextup.ts index db314e34..6df5d360 100644 --- a/api/src/controllers/profiles/nextup.ts +++ b/api/src/controllers/profiles/nextup.ts @@ -39,7 +39,7 @@ const nextupSort = Sort( lastPlayed: watchlist.lastPlayedAt, }, { - default: ["lastPlayed"], + default: ["-lastPlayed"], tablePk: entries.pk, }, ); @@ -85,7 +85,6 @@ export const nextup = new Elysia({ tags: ["profiles"] }) const { pk, name, ...transCol } = getColumns(transQ); const { - kind, externalId, order, seasonNumber, @@ -100,6 +99,8 @@ export const nextup = new Elysia({ tags: ["profiles"] }) ...transCol, videos: entryVideosQ.videos, progress: mapProgress({ aliased: true }), + // specials don't have an `episodeNumber` but a `number` field. + number: episodeNumber, // assign more restrained types to make typescript happy. externalId: sql`${externalId}`, diff --git a/api/src/controllers/shows/logic.ts b/api/src/controllers/shows/logic.ts index 40b72b5f..71c6e567 100644 --- a/api/src/controllers/shows/logic.ts +++ b/api/src/controllers/shows/logic.ts @@ -196,11 +196,7 @@ const showRelations = { .limit(1) .as("firstEntry"); }, - nextEntry: ({ - languages, - }: { - languages: string[]; - }) => { + nextEntry: ({ languages }: { languages: string[] }) => { const transQ = db .selectDistinctOn([entryTranslations.pk]) .from(entryTranslations) diff --git a/api/src/models/serie.ts b/api/src/models/serie.ts index 3e4c3f2a..8a9bd942 100644 --- a/api/src/models/serie.ts +++ b/api/src/models/serie.ts @@ -82,6 +82,7 @@ export const FullSerie = t.Intersect([ translations: t.Optional(TranslationRecord(SerieTranslation)), studios: t.Optional(t.Array(Studio)), firstEntry: t.Optional(Entry), + nextEntry: t.Optional(t.Nullable(Entry)), }), ]); export type FullSerie = Prettify;