release / govulncheck (push) Successful in 15s
release / web (push) Failing after 17s
release / go (push) Successful in 1m13s
release / integration (push) Successful in 4m56s
release / android (push) Successful in 5m9s
release / Build signed APK (releases and dev) (push) Successful in 5m19s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
Migration 0091 drops lidarr_config and renames the quarantine tables, types, indexes and the history column off the Lidarr name. The Integrations Lidarr card, the Reports "Delete via Lidarr" action, the merge and remove-track unmonitor options, the Lidarr audit actions and error codes go, on the server, web and Android. The README describes acquisition as it is now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
96 lines
3.3 KiB
SQL
96 lines
3.3 KiB
SQL
-- name: UpsertQuarantine :one
|
|
-- Insert a new quarantine row, or update reason/notes if the user has
|
|
-- already flagged this track.
|
|
INSERT INTO quarantine (user_id, track_id, reason, notes)
|
|
VALUES ($1, $2, $3, $4)
|
|
ON CONFLICT (user_id, track_id) DO UPDATE SET
|
|
reason = EXCLUDED.reason,
|
|
notes = EXCLUDED.notes,
|
|
created_at = now()
|
|
RETURNING user_id, track_id, reason, notes, created_at;
|
|
|
|
-- name: DeleteQuarantine :one
|
|
-- Removes the caller's row. Returns the deleted row so the handler can
|
|
-- distinguish "no row existed" (zero rows -> ErrNoRows) from success.
|
|
DELETE FROM quarantine
|
|
WHERE user_id = $1 AND track_id = $2
|
|
RETURNING user_id, track_id, reason, notes, created_at;
|
|
|
|
-- name: ListQuarantineForUser :many
|
|
-- Caller's own quarantines plus just the joined fields the SPA's
|
|
-- /library/hidden actually renders. Embedding the full tracks/albums/artists
|
|
-- structs would drag ~28 columns of file_path / sort_* / mbid / etc. that
|
|
-- the row card never uses.
|
|
SELECT
|
|
sqlc.embed(q),
|
|
t.id AS track_id_join,
|
|
t.title AS track_title,
|
|
t.duration_ms AS track_duration_ms,
|
|
al.id AS album_id,
|
|
al.title AS album_title,
|
|
al.cover_art_path AS album_cover_art_path,
|
|
ar.id AS artist_id,
|
|
ar.name AS artist_name
|
|
FROM quarantine q
|
|
JOIN tracks t ON t.id = q.track_id
|
|
JOIN albums al ON al.id = t.album_id
|
|
JOIN artists ar ON ar.id = t.artist_id
|
|
WHERE q.user_id = $1
|
|
ORDER BY q.created_at DESC;
|
|
|
|
-- name: ListAdminQuarantineQueue :many
|
|
-- Aggregated admin queue. One row per track. The handler post-processes
|
|
-- the rows it gets from this query plus a per-track ListQuarantineReports
|
|
-- call to materialize reason_counts and the per-user reports list.
|
|
SELECT
|
|
t.id AS track_id,
|
|
t.title AS track_title,
|
|
ar.name AS artist_name,
|
|
al.title AS album_title,
|
|
al.id AS album_id,
|
|
count(q.user_id)::int AS report_count,
|
|
max(q.created_at)::timestamptz AS latest_at
|
|
FROM quarantine q
|
|
JOIN tracks t ON t.id = q.track_id
|
|
JOIN albums al ON al.id = t.album_id
|
|
JOIN artists ar ON ar.id = t.artist_id
|
|
GROUP BY t.id, ar.name, al.title, al.id
|
|
ORDER BY max(q.created_at) DESC;
|
|
|
|
-- name: ListQuarantineReportsForTrack :many
|
|
-- Per-user reports for a single track. Returned by ListAdminQuarantineQueue
|
|
-- post-processing and exposed expandable in the SPA admin queue rows.
|
|
SELECT
|
|
q.user_id,
|
|
u.username,
|
|
q.reason,
|
|
q.notes,
|
|
q.created_at
|
|
FROM quarantine q
|
|
JOIN users u ON u.id = q.user_id
|
|
WHERE q.track_id = $1
|
|
ORDER BY q.created_at DESC;
|
|
|
|
-- name: DeleteQuarantineForTrack :exec
|
|
-- Clears all per-user rows for a given track. Used by Resolve and the
|
|
-- two delete actions. Caller writes the audit row separately before
|
|
-- this fires (so we can capture the affected_users count).
|
|
DELETE FROM quarantine WHERE track_id = $1;
|
|
|
|
-- name: CountQuarantineForTrack :one
|
|
-- Reads affected_users for the audit row before the delete fires.
|
|
SELECT count(*)::int FROM quarantine WHERE track_id = $1;
|
|
|
|
-- name: WriteQuarantineAction :one
|
|
-- Audit row for an admin destructive action.
|
|
INSERT INTO quarantine_actions (
|
|
track_id, track_title, artist_name, album_title,
|
|
action, admin_id, affected_users
|
|
) VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
RETURNING *;
|
|
|
|
-- name: ListQuarantineActions :many
|
|
SELECT * FROM quarantine_actions
|
|
ORDER BY created_at DESC
|
|
LIMIT $1;
|