Files
minstrel/internal/api/admin_summary.go
T
bvandeusenandClaude Opus 5.5 55c7497ca7
release / go (push) Successful in 1m54s
release / web (push) Failing after 5s
release / integration (push) Failing after 3m44s
release / govulncheck (push) Successful in 20s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 19s
release / android (push) Canceled after 2m37s
feat: Minstrel stops acquiring music and drops Discover
Minstrel is now a viewer of the library it is pointed at. Finding,
downloading and filing music moves out of it.

Removed from the server:
- the request flow (requests, approval, auto-approve) and the wanted list,
  follows, release profiles and release blocks;
- searching indexers, the download clients, the importer, the album
  lifecycle and missing-file re-acquisition;
- the catalogue's discography, search and art (the MusicBrainz release and
  track-list cache stays, for the duplicate resolver);
- Discover: its suggestions of artists not in the library, snoozes, the
  candidate-artist tag enrichment and its tuning scope;
- writes to acquisition tables from moving the library folder and from
  merging duplicates, the want-list join on Suspect sources, the sealing of
  acquisition credentials, and the release-group lookup only
  re-acquisition used.

Settling a wrong-slot duplicate no longer sets the release aside: the
copies go and their slots show as missing until a good copy is in the
library.

Removed from the web: Admin > Acquisition and Requests, /requests,
/discover, Follow on the artist page, the auto-approve toggle, and the
Collection's wanted-list tabs. The Collection is now the library's health:
an overview, Reports, Duplicates, Suspect sources and Missing files. The
README and docs no longer describe getting music.

The tables stay for now; a later migration drops them. The request
notification kinds and the Android screens are still to go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 20:51:14 -05:00

56 lines
1.6 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:
// every queue an admin acts on, in one response, so each admin page pays one
// cheap read for its rail.
type adminSummaryView struct {
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{
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))
}