Files
minstrel/internal/api/admin_summary.go
T
bvandeusenandClaude Opus 5.5 89a2653995
release / govulncheck (push) Successful in 16s
release / web (push) Failing after 1m18s
release / go (push) Successful in 1m36s
release / integration (push) Successful in 5m27s
release / android (push) Successful in 5m28s
release / Build signed APK (releases and dev) (push) Successful in 5m38s
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
feat: Admin › Reports is one queue of broken tracks, whether a listener flagged it or it failed to play, one row per track with one set of actions (M503 #5606)
- /admin/reports folds the quarantine queue and the unresolved playback
  errors into one row per track, newest first: who flagged it and why,
  what failed and for whom, the file, with Resolve (clears the reports and
  marks the errors fixed), Play, Copy details, Delete file and, for an album
  Lidarr holds, Delete via Lidarr.
- One delete path: Delete file removes the track, and its reports and
  errors go with the row.
- A Handled tab shows what was done: reports cleared, files deleted,
  errors marked fixed or ignored.
- The summary counts reports by track across both sources, so the rail,
  the Overview and the page agree.
- /admin/quarantine and /admin/playback-errors redirect to Reports: the
  notifications and the Android app link to them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 10:53:58 -04:00

58 lines
1.8 KiB
Go

package api
import (
"net/http"
"github.com/jackc/pgx/v5/pgtype"
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
)
// adminQueueView is one queue that waits on a person: how many, and since
// when the oldest of them has waited (null when the queue is empty).
type adminQueueView struct {
Count int64 `json:"count"`
Since *string `json:"since"`
}
// adminSummaryView is what the admin rail and the Overview's verdict read
// (#5605): every queue an admin acts on, in one response, so each admin page
// pays one cheap read for its rail.
type adminSummaryView struct {
Requests adminQueueView `json:"requests"`
Reports adminQueueView `json:"reports"`
Duplicates adminQueueView `json:"duplicates"`
Suspect adminQueueView `json:"suspect"`
Missing adminQueueView `json:"missing"`
}
func queueView(count int64, since pgtype.Timestamptz) adminQueueView {
v := adminQueueView{Count: count}
if count > 0 && since.Valid {
s := formatTimestamp(since)
v.Since = &s
}
return v
}
func adminSummaryFrom(row dbq.AdminSummaryRow) adminSummaryView {
return adminSummaryView{
Requests: queueView(row.Requests, row.RequestsSince),
Reports: queueView(row.Reports, row.ReportsSince),
Duplicates: queueView(row.Duplicates, row.DuplicatesSince),
Suspect: queueView(row.Suspect, row.SuspectSince),
Missing: queueView(row.Missing, row.MissingSince),
}
}
// handleGetAdminSummary implements GET /api/admin/summary.
func (h *handlers) handleGetAdminSummary(w http.ResponseWriter, r *http.Request) {
row, err := dbq.New(h.pool).AdminSummary(r.Context())
if err != nil {
h.logger.Error("admin: summary", "err", err)
writeAdminJSONErr(w, http.StatusInternalServerError, "server_error")
return
}
writeJSON(w, http.StatusOK, adminSummaryFrom(row))
}