watchlist: only set updated_at when marking anime as completed
This commit is contained in:
@@ -71,6 +71,7 @@ func (s *Service) AddEntry(ctx context.Context, userID string, req AddRequest) e
|
|||||||
Status: req.Status,
|
Status: req.Status,
|
||||||
CurrentEpisode: sql.NullInt64{Int64: 0, Valid: false},
|
CurrentEpisode: sql.NullInt64{Int64: 0, Valid: false},
|
||||||
CurrentTimeSeconds: 0,
|
CurrentTimeSeconds: 0,
|
||||||
|
UpdatedAt: sql.NullTime{Valid: false},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to update watchlist: %w", err)
|
return fmt.Errorf("failed to update watchlist: %w", err)
|
||||||
|
|||||||
@@ -31,19 +31,17 @@ SELECT * FROM anime WHERE id = ? LIMIT 1;
|
|||||||
|
|
||||||
-- name: UpsertWatchListEntry :one
|
-- name: UpsertWatchListEntry :one
|
||||||
INSERT INTO watch_list_entry (id, user_id, anime_id, status, current_episode, current_time_seconds, updated_at)
|
INSERT INTO watch_list_entry (id, user_id, anime_id, status, current_episode, current_time_seconds, updated_at)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
|
VALUES (?, ?, ?, ?, ?, ?, NULL)
|
||||||
ON CONFLICT (user_id, anime_id) DO UPDATE SET
|
ON CONFLICT (user_id, anime_id) DO UPDATE SET
|
||||||
status = excluded.status,
|
status = excluded.status,
|
||||||
current_episode = excluded.current_episode,
|
current_episode = excluded.current_episode,
|
||||||
current_time_seconds = excluded.current_time_seconds,
|
current_time_seconds = excluded.current_time_seconds
|
||||||
updated_at = CURRENT_TIMESTAMP
|
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
|
|
||||||
-- name: SaveWatchProgress :exec
|
-- name: SaveWatchProgress :exec
|
||||||
UPDATE watch_list_entry
|
UPDATE watch_list_entry
|
||||||
SET current_episode = ?,
|
SET current_episode = ?,
|
||||||
current_time_seconds = ?,
|
current_time_seconds = ?
|
||||||
updated_at = CURRENT_TIMESTAMP
|
|
||||||
WHERE user_id = ? AND anime_id = ?;
|
WHERE user_id = ? AND anime_id = ?;
|
||||||
|
|
||||||
-- name: UpsertContinueWatchingEntry :one
|
-- name: UpsertContinueWatchingEntry :one
|
||||||
|
|||||||
@@ -687,8 +687,7 @@ func (q *Queries) MarkRelationsSynced(ctx context.Context, id int64) error {
|
|||||||
const saveWatchProgress = `-- name: SaveWatchProgress :exec
|
const saveWatchProgress = `-- name: SaveWatchProgress :exec
|
||||||
UPDATE watch_list_entry
|
UPDATE watch_list_entry
|
||||||
SET current_episode = ?,
|
SET current_episode = ?,
|
||||||
current_time_seconds = ?,
|
current_time_seconds = ?
|
||||||
updated_at = CURRENT_TIMESTAMP
|
|
||||||
WHERE user_id = ? AND anime_id = ?
|
WHERE user_id = ? AND anime_id = ?
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -847,12 +846,11 @@ func (q *Queries) UpsertContinueWatchingEntry(ctx context.Context, arg UpsertCon
|
|||||||
|
|
||||||
const upsertWatchListEntry = `-- name: UpsertWatchListEntry :one
|
const upsertWatchListEntry = `-- name: UpsertWatchListEntry :one
|
||||||
INSERT INTO watch_list_entry (id, user_id, anime_id, status, current_episode, current_time_seconds, updated_at)
|
INSERT INTO watch_list_entry (id, user_id, anime_id, status, current_episode, current_time_seconds, updated_at)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
|
VALUES (?, ?, ?, ?, ?, ?, NULL)
|
||||||
ON CONFLICT (user_id, anime_id) DO UPDATE SET
|
ON CONFLICT (user_id, anime_id) DO UPDATE SET
|
||||||
status = excluded.status,
|
status = excluded.status,
|
||||||
current_episode = excluded.current_episode,
|
current_episode = excluded.current_episode,
|
||||||
current_time_seconds = excluded.current_time_seconds,
|
current_time_seconds = excluded.current_time_seconds
|
||||||
updated_at = CURRENT_TIMESTAMP
|
|
||||||
RETURNING id, user_id, anime_id, status, created_at, updated_at, current_episode, last_episode_at, current_time_seconds
|
RETURNING id, user_id, anime_id, status, created_at, updated_at, current_episode, last_episode_at, current_time_seconds
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -863,6 +861,7 @@ type UpsertWatchListEntryParams struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
CurrentEpisode sql.NullInt64 `json:"current_episode"`
|
CurrentEpisode sql.NullInt64 `json:"current_episode"`
|
||||||
CurrentTimeSeconds float64 `json:"current_time_seconds"`
|
CurrentTimeSeconds float64 `json:"current_time_seconds"`
|
||||||
|
UpdatedAt sql.NullTime `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) UpsertWatchListEntry(ctx context.Context, arg UpsertWatchListEntryParams) (WatchListEntry, error) {
|
func (q *Queries) UpsertWatchListEntry(ctx context.Context, arg UpsertWatchListEntryParams) (WatchListEntry, error) {
|
||||||
@@ -873,6 +872,7 @@ func (q *Queries) UpsertWatchListEntry(ctx context.Context, arg UpsertWatchListE
|
|||||||
arg.Status,
|
arg.Status,
|
||||||
arg.CurrentEpisode,
|
arg.CurrentEpisode,
|
||||||
arg.CurrentTimeSeconds,
|
arg.CurrentTimeSeconds,
|
||||||
|
arg.UpdatedAt,
|
||||||
)
|
)
|
||||||
var i WatchListEntry
|
var i WatchListEntry
|
||||||
err := row.Scan(
|
err := row.Scan(
|
||||||
|
|||||||
Reference in New Issue
Block a user