change watch history duration watched to float

This commit is contained in:
Pas 2026-01-16 19:11:47 -07:00
parent c8079ff2c8
commit 011a5a7791
4 changed files with 15 additions and 9 deletions

View file

@ -0,0 +1,6 @@
-- AlterTable
ALTER TABLE "user_group_order" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "watch_history" ALTER COLUMN "duration" SET DATA TYPE DOUBLE PRECISION,
ALTER COLUMN "watched" SET DATA TYPE DOUBLE PRECISION;

View file

@ -148,8 +148,8 @@ model watch_history {
season_id String? @db.VarChar(255) season_id String? @db.VarChar(255)
episode_id String? @db.VarChar(255) episode_id String? @db.VarChar(255)
meta Json meta Json
duration BigInt duration Float
watched BigInt watched Float
watched_at DateTime @db.Timestamptz(0) watched_at DateTime @db.Timestamptz(0)
completed Boolean @default(false) completed Boolean @default(false)
season_number Int? season_number Int?

View file

@ -77,8 +77,8 @@ export default defineEventHandler(async event => {
id: existingItem.id, id: existingItem.id,
}, },
data: { data: {
duration: BigInt(validatedBody.duration), duration: parseFloat(validatedBody.duration),
watched: BigInt(validatedBody.watched), watched: parseFloat(validatedBody.watched),
watched_at: watchedAt, watched_at: watchedAt,
completed: validatedBody.completed, completed: validatedBody.completed,
meta: validatedBody.meta, meta: validatedBody.meta,
@ -95,8 +95,8 @@ export default defineEventHandler(async event => {
episode_id: validatedBody.episodeId || null, episode_id: validatedBody.episodeId || null,
season_number: validatedBody.seasonNumber || null, season_number: validatedBody.seasonNumber || null,
episode_number: validatedBody.episodeNumber || null, episode_number: validatedBody.episodeNumber || null,
duration: BigInt(validatedBody.duration), duration: parseFloat(validatedBody.duration),
watched: BigInt(validatedBody.watched), watched: parseFloat(validatedBody.watched),
watched_at: watchedAt, watched_at: watchedAt,
completed: validatedBody.completed, completed: validatedBody.completed,
meta: validatedBody.meta, meta: validatedBody.meta,
@ -115,8 +115,8 @@ export default defineEventHandler(async event => {
seasonNumber: watchHistoryItem.season_number, seasonNumber: watchHistoryItem.season_number,
episodeNumber: watchHistoryItem.episode_number, episodeNumber: watchHistoryItem.episode_number,
meta: watchHistoryItem.meta, meta: watchHistoryItem.meta,
duration: Number(watchHistoryItem.duration), duration: watchHistoryItem.duration,
watched: Number(watchHistoryItem.watched), watched: watchHistoryItem.watched,
watchedAt: watchHistoryItem.watched_at.toISOString(), watchedAt: watchHistoryItem.watched_at.toISOString(),
completed: watchHistoryItem.completed, completed: watchHistoryItem.completed,
updatedAt: watchHistoryItem.updated_at.toISOString(), updatedAt: watchHistoryItem.updated_at.toISOString(),