fix: address code review findings

- Fix duplicate Telegram notifications: SyncArtistDiscography no longer wipes
  notifications_sent for the whole artist on every cache-miss re-sync; only
  markers for releases that disappear are pruned (FK-safe via INSERT OR REPLACE
  + rgid NOT IN (...)).
- Cache empty MusicBrainz discographies via a new artist_settings.last_synced
  column (migration 009) so zero-release artists honor the TTL instead of being
  re-fetched every cycle.
- Wire the Web UI server and Telegram notifier scheduler into main.run/NewApp.
- Guard startPeriodicSync against overlapping syncs with a done-channel slot.
- Add server.public_url config; NewServerWithConfig derives reachable links
  and no longer advertises the 0.0.0.0 bind address.
- Web handlers: use scanner.ScanArtist per artist, drop always-false
  releaseIgnored lookup and dead endsWith, thread configured threshold.
- Limit :memory: DB pool to one connection so migrations and queries share the
  same in-memory store.
This commit is contained in:
2026-07-19 23:38:33 +03:00
parent e493a4d228
commit 389d177d85
15 changed files with 386 additions and 126 deletions

View File

@@ -27,16 +27,22 @@ type Server struct {
// uiBaseURL is the externally reachable base URL of the dashboard (scheme +
// host), used to build links in notifications and elsewhere. Optional.
uiBaseURL string
// threshold is the fuzzy-similarity cutoff used when scanning for missing
// releases; 0 means use the scanner default.
threshold float64
}
// NewServer constructs a dashboard Server bound to the given DB and server
// config. uiBaseURL is the externally reachable origin (e.g.
// "http://localhost:8080") used when rendering absolute links; pass "" to omit.
func NewServer(cfg *config.ServerConfig, db *database.DB, uiBaseURL string) *Server {
// threshold is the fuzzy-similarity cutoff (0 → scanner default).
func NewServer(cfg *config.ServerConfig, db *database.DB, uiBaseURL string, threshold float64) *Server {
s := &Server{
cfg: cfg,
db: db,
uiBaseURL: strings.TrimRight(uiBaseURL, "/"),
threshold: threshold,
}
mux := http.NewServeMux()
mux.HandleFunc("/", s.handleDashboard)