fix: address code review findings

- Honor ignore_singles/ignore_compilations at scanner read time so toggles
  take effect immediately on the dashboard, artist page, and digest instead
  of waiting for the MusicBrainz cache to expire and prune rows.
- Run notifier notify synchronously in the scheduler loop to avoid overlapping
  read-send-mark runs double-sending the digest.
- Show artist name (with ID fallback) on the archive page instead of raw IDs.
- Select last_synced in GetAllArtistSettings for contract consistency.
- Fix stale startPeriodicSync comment and remove redundant error var.
- Remove dead ignored-branch from the artist template (never rendered).
- Add tests: CSRF sameOrigin, ArtistCacheFresh, secondary_types round-trip,
  and scanner type-toggle filtering.
- Update Specification.md schema/config to reflect mbid, last_synced,
  secondary_types, sync.interval, and server.public_url.
This commit is contained in:
2026-07-20 06:18:21 +03:00
parent f5b0034b4d
commit a8aa445d94
13 changed files with 402 additions and 31 deletions

View File

@@ -68,6 +68,7 @@ type LocalAlbumView struct {
// artist detail page, including the ignore toggle form target.
type MissingReleaseView struct {
ArtistID string
ArtistName string
RGID string
Title string
Type string
@@ -189,14 +190,18 @@ func (s *Server) handleArchive(w http.ResponseWriter, r *http.Request) {
data := &ArchiveData{UIBaseURL: s.uiBaseURL}
for _, rel := range ignored {
data.Releases = append(data.Releases, MissingReleaseView{
view := MissingReleaseView{
ArtistID: rel.ArtistID,
RGID: rel.RGID,
Title: rel.Title,
Type: rel.Type,
ReleaseDate: rel.ReleaseDate,
Ignored: true,
})
}
if settings, err := database.GetArtistSettings(s.db, rel.ArtistID); err == nil {
view.ArtistName = settings.Name
}
data.Releases = append(data.Releases, view)
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
@@ -271,8 +276,7 @@ func (s *Server) ignoreOrRestore(w http.ResponseWriter, r *http.Request) {
// A 0-rows-affected error means the release was already removed by a
// concurrent re-sync (it disappeared from MusicBrainz). That is benign:
// redirect back rather than surfacing a 500 for a now-nonexistent row.
var notFoundErr error = database.ErrReleaseNotFound
if errors.Is(err, notFoundErr) {
if errors.Is(err, database.ErrReleaseNotFound) {
http.Redirect(w, r, "/artist/"+id, http.StatusSeeOther)
return
}