fix: address code review findings
This commit is contained in:
@@ -97,8 +97,8 @@ func (a *App) Close() {
|
|||||||
func (a *App) run(ctx context.Context) error {
|
func (a *App) run(ctx context.Context) error {
|
||||||
// Compute-only scanner hook: scan all monitored artists for missing
|
// Compute-only scanner hook: scan all monitored artists for missing
|
||||||
// releases and log the count. Notifier/Web UI are out of scope for this
|
// releases and log the count. Notifier/Web UI are out of scope for this
|
||||||
// plan, so results are only logged. This call is non-blocking and
|
// plan, so results are only logged. ScanAll is a blocking DB walk over
|
||||||
// goroutine-safe; it observes ctx cancellation and returns early.
|
// every monitored artist; it observes ctx cancellation and returns early.
|
||||||
missing, err := scanner.ScanAll(ctx, a.db, a.cfg.Scanner.FuzzyThreshold)
|
missing, err := scanner.ScanAll(ctx, a.db, a.cfg.Scanner.FuzzyThreshold)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
|
|||||||
@@ -47,10 +47,13 @@ type TelegramConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ScannerConfig holds scanner engine parameters.
|
// ScannerConfig holds scanner engine parameters.
|
||||||
|
//
|
||||||
|
// Bootleg/Compilation filtering is intentionally unconditional: bootlegs,
|
||||||
|
// promotions, and pseudo-releases are always excluded (musicbrainz/api.go),
|
||||||
|
// and compilations are always included. These are not user-toggleable, so
|
||||||
|
// there are no corresponding config fields.
|
||||||
type ScannerConfig struct {
|
type ScannerConfig struct {
|
||||||
FuzzyThreshold float64 `yaml:"fuzzy_threshold"`
|
FuzzyThreshold float64 `yaml:"fuzzy_threshold"`
|
||||||
IgnoreBootlegs bool `yaml:"ignore_bootlegs"`
|
|
||||||
IncludeCompilations bool `yaml:"include_compilations"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadConfig reads a YAML file from path, parses it, applies defaults,
|
// LoadConfig reads a YAML file from path, parses it, applies defaults,
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ telegram:
|
|||||||
|
|
||||||
scanner:
|
scanner:
|
||||||
fuzzy_threshold: 0.9
|
fuzzy_threshold: 0.9
|
||||||
ignore_bootlegs: true
|
|
||||||
include_compilations: false
|
|
||||||
`
|
`
|
||||||
if err := os.WriteFile(path, []byte(yaml), 0644); err != nil {
|
if err := os.WriteFile(path, []byte(yaml), 0644); err != nil {
|
||||||
t.Fatalf("failed to write config: %v", err)
|
t.Fatalf("failed to write config: %v", err)
|
||||||
@@ -68,12 +66,6 @@ scanner:
|
|||||||
if cfg.Scanner.FuzzyThreshold != 0.9 {
|
if cfg.Scanner.FuzzyThreshold != 0.9 {
|
||||||
t.Errorf("expected fuzzy_threshold 0.9, got %f", cfg.Scanner.FuzzyThreshold)
|
t.Errorf("expected fuzzy_threshold 0.9, got %f", cfg.Scanner.FuzzyThreshold)
|
||||||
}
|
}
|
||||||
if !cfg.Scanner.IgnoreBootlegs {
|
|
||||||
t.Error("expected ignore_bootlegs true")
|
|
||||||
}
|
|
||||||
if cfg.Scanner.IncludeCompilations {
|
|
||||||
t.Error("expected include_compilations false")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadConfig_Defaults(t *testing.T) {
|
func TestLoadConfig_Defaults(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user