mirror of
https://github.com/p-stream/backend.git
synced 2026-04-19 08:02:17 +00:00
Fixed watch history and make it consistent with progress items.
This commit is contained in:
parent
16f9905028
commit
8e8fd83164
2 changed files with 25 additions and 2 deletions
|
|
@ -20,4 +20,27 @@ WHERE "season_id" IS NULL;
|
|||
|
||||
UPDATE "progress_items"
|
||||
SET "episode_id" = E'\n'
|
||||
WHERE "episode_id" IS NULL;
|
||||
|
||||
-- Normalize existing movie watch_history rows: NULL → '\n' sentinel
|
||||
-- Same pattern as progress_items above.
|
||||
|
||||
-- Deduplicate: if both a NULL row and a '\n' row exist for the same movie,
|
||||
-- keep the '\n' row and delete the NULL one.
|
||||
DELETE FROM "watch_history" a
|
||||
USING "watch_history" b
|
||||
WHERE a."tmdb_id" = b."tmdb_id"
|
||||
AND a."user_id" = b."user_id"
|
||||
AND a."season_id" IS NULL
|
||||
AND a."episode_id" IS NULL
|
||||
AND b."season_id" = E'\n'
|
||||
AND b."episode_id" = E'\n';
|
||||
|
||||
-- Convert remaining NULL rows to '\n'
|
||||
UPDATE "watch_history"
|
||||
SET "season_id" = E'\n'
|
||||
WHERE "season_id" IS NULL;
|
||||
|
||||
UPDATE "watch_history"
|
||||
SET "episode_id" = E'\n'
|
||||
WHERE "episode_id" IS NULL;
|
||||
|
|
@ -113,8 +113,8 @@ export default defineEventHandler(async event => {
|
|||
id: watchHistoryItem.id,
|
||||
tmdbId: watchHistoryItem.tmdb_id,
|
||||
userId: watchHistoryItem.user_id,
|
||||
seasonId: watchHistoryItem.season_id,
|
||||
episodeId: watchHistoryItem.episode_id,
|
||||
seasonId: watchHistoryItem.season_id === '\n' ? null : watchHistoryItem.season_id,
|
||||
episodeId: watchHistoryItem.episode_id === '\n' ? null : watchHistoryItem.episode_id,
|
||||
seasonNumber: watchHistoryItem.season_number,
|
||||
episodeNumber: watchHistoryItem.episode_number,
|
||||
meta: watchHistoryItem.meta,
|
||||
|
|
|
|||
Loading…
Reference in a new issue