release / go (push) Successful in 2m7s
release / web (push) Successful in 1m25s
release / govulncheck (push) Successful in 21s
release / integration (push) Successful in 4m30s
release / android (push) Successful in 4m39s
release / Build signed APK (push) Successful in 5m10s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 29s
release / Verify release artifacts (tag releases only) (push) Skipped
- Module path: github.com/Fabled-Sword/minstrel, in go.mod, every import and the Dockerfile's version ldflags. - buildinfo.ProjectURL, the contact outside services see in Minstrel's User-Agent: https://github.com/Fabled-Sword/minstrel. - README's compose example pulls ghcr.io/fabled-sword/minstrel:latest. - docs/security.md sends problem reports to the GitHub issues. - The demo-library stack builds Minstrel from the checkout, since :dev is not published to GHCR. - hygiene.go's same-site example uses example.com names. The workbench CI (.gitea/, ci/, export-ignored) still builds and publishes :dev to the private registry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
|
|
"github.com/Fabled-Sword/minstrel/internal/apierror"
|
|
"github.com/Fabled-Sword/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)
|
|
writeErr(w, apierror.Internal(err))
|
|
return
|
|
}
|
|
writeJSON(w, http.StatusOK, adminSummaryFrom(row))
|
|
}
|