From bc8e87f34376ac18ee11dd2696d1feef1846b9c3 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 20 Jul 2025 15:12:33 +0200 Subject: [PATCH] Make history's `time` non nullable (it was never null anyways) --- api/src/db/schema/history.ts | 2 +- api/src/models/history.ts | 10 ++++------ front/src/models/entry.ts | 2 +- front/src/models/extra.ts | 2 +- front/src/models/video.ts | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/api/src/db/schema/history.ts b/api/src/db/schema/history.ts index 84b8011b..de2a4420 100644 --- a/api/src/db/schema/history.ts +++ b/api/src/db/schema/history.ts @@ -18,7 +18,7 @@ export const history = schema.table( .references(() => entries.pk, { onDelete: "cascade" }), videoPk: integer().references(() => videos.pk, { onDelete: "set null" }), percent: integer().notNull().default(0), - time: integer(), + time: integer().notNull().default(0), playedDate: timestamp({ withTimezone: true, mode: "iso" }) .notNull() .default(sql`now()`), diff --git a/api/src/models/history.ts b/api/src/models/history.ts index 9d76184c..541153fd 100644 --- a/api/src/models/history.ts +++ b/api/src/models/history.ts @@ -3,15 +3,13 @@ import { comment } from "~/utils"; export const Progress = t.Object({ percent: t.Integer({ minimum: 0, maximum: 100 }), - time: t.Nullable( - t.Integer({ - minimum: 0, - description: comment` + time: t.Integer({ + minimum: 0, + description: comment` When this episode was stopped (in seconds since the start). This value is null if the entry was never watched or is finished. `, - }), - ), + }), playedDate: t.Nullable(t.String({ format: "date-time" })), videoId: t.Nullable( t.String({ diff --git a/front/src/models/entry.ts b/front/src/models/entry.ts index d11fad2a..3680efe2 100644 --- a/front/src/models/entry.ts +++ b/front/src/models/entry.ts @@ -29,7 +29,7 @@ const Base = z.object({ ), progress: z.object({ percent: z.int().min(0).max(100), - time: z.int().min(0).nullable(), + time: z.int().min(0), playedDate: zdate().nullable(), videoId: z.string().nullable(), }), diff --git a/front/src/models/extra.ts b/front/src/models/extra.ts index 1c2d69dd..46cd58ba 100644 --- a/front/src/models/extra.ts +++ b/front/src/models/extra.ts @@ -22,7 +22,7 @@ export const Extra = z.object({ progress: z.object({ percent: z.int().min(0).max(100), - time: z.int().min(0).nullable(), + time: z.int().min(0), playedDate: zdate().nullable(), }), }); diff --git a/front/src/models/video.ts b/front/src/models/video.ts index f4f52e5f..06004a15 100644 --- a/front/src/models/video.ts +++ b/front/src/models/video.ts @@ -39,7 +39,7 @@ export const FullVideo = Video.extend({ slugs: z.array(z.string()), progress: z.object({ percent: z.int().min(0).max(100), - time: z.int().min(0).nullable(), + time: z.int().min(0), playedDate: zdate().nullable(), videoId: z.string().nullable(), }),