feat: set status to completed on anime completion

Check existing watchlist status — if already completed, just clear
progress and remove from continue watching. Otherwise upsert with
status 'completed'.
This commit is contained in:
2026-05-13 18:28:33 +02:00
parent 28e8b322d0
commit efbce87d5c
3 changed files with 23 additions and 0 deletions

View File

@@ -323,6 +323,24 @@ func (s *playbackService) BuildWatchData(ctx context.Context, animeID int, title
}
func (s *playbackService) CompleteAnime(ctx context.Context, userID string, animeID int64) error {
entry, err := s.repo.GetWatchListEntry(ctx, db.GetWatchListEntryParams{
UserID: userID,
AnimeID: animeID,
})
if err != nil || entry.Status != "completed" {
_, err = s.repo.UpsertWatchListEntry(ctx, db.UpsertWatchListEntryParams{
ID: uuid.New().String(),
UserID: userID,
AnimeID: animeID,
Status: "completed",
CurrentEpisode: sql.NullInt64{Valid: false},
CurrentTimeSeconds: 0,
})
if err != nil {
return err
}
}
_ = s.repo.DeleteContinueWatchingEntry(ctx, db.DeleteContinueWatchingEntryParams{
UserID: userID,
AnimeID: animeID,