diff --git a/prisma/migrations/20260117021109_change_watch_history_duration_watched_to_float/migration.sql b/prisma/migrations/20260117021109_change_watch_history_duration_watched_to_float/migration.sql new file mode 100644 index 0000000..03554fc --- /dev/null +++ b/prisma/migrations/20260117021109_change_watch_history_duration_watched_to_float/migration.sql @@ -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; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml index 648c57f..044d57c 100644 --- a/prisma/migrations/migration_lock.toml +++ b/prisma/migrations/migration_lock.toml @@ -1,3 +1,3 @@ # Please do not edit this file manually # It should be added in your version-control system (e.g., Git) -provider = "postgresql" \ No newline at end of file +provider = "postgresql" diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 066b0f5..4075416 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -148,8 +148,8 @@ model watch_history { season_id String? @db.VarChar(255) episode_id String? @db.VarChar(255) meta Json - duration BigInt - watched BigInt + duration Float + watched Float watched_at DateTime @db.Timestamptz(0) completed Boolean @default(false) season_number Int? diff --git a/server/routes/users/[id]/watch-history/[tmdbid]/index.ts b/server/routes/users/[id]/watch-history/[tmdbid]/index.ts index 192dcaf..c55082c 100644 --- a/server/routes/users/[id]/watch-history/[tmdbid]/index.ts +++ b/server/routes/users/[id]/watch-history/[tmdbid]/index.ts @@ -77,8 +77,8 @@ export default defineEventHandler(async event => { id: existingItem.id, }, data: { - duration: BigInt(validatedBody.duration), - watched: BigInt(validatedBody.watched), + duration: parseFloat(validatedBody.duration), + watched: parseFloat(validatedBody.watched), watched_at: watchedAt, completed: validatedBody.completed, meta: validatedBody.meta, @@ -95,8 +95,8 @@ export default defineEventHandler(async event => { episode_id: validatedBody.episodeId || null, season_number: validatedBody.seasonNumber || null, episode_number: validatedBody.episodeNumber || null, - duration: BigInt(validatedBody.duration), - watched: BigInt(validatedBody.watched), + duration: parseFloat(validatedBody.duration), + watched: parseFloat(validatedBody.watched), watched_at: watchedAt, completed: validatedBody.completed, meta: validatedBody.meta, @@ -115,8 +115,8 @@ export default defineEventHandler(async event => { seasonNumber: watchHistoryItem.season_number, episodeNumber: watchHistoryItem.episode_number, meta: watchHistoryItem.meta, - duration: Number(watchHistoryItem.duration), - watched: Number(watchHistoryItem.watched), + duration: watchHistoryItem.duration, + watched: watchHistoryItem.watched, watchedAt: watchHistoryItem.watched_at.toISOString(), completed: watchHistoryItem.completed, updatedAt: watchHistoryItem.updated_at.toISOString(),