Skip to content

feat: Configurable minimum-score threshold (+ fix for ranking authors with initials) - #235

Open
NichCodes wants to merge 2 commits into
kikootwo:mainfrom
NichCodes:fix/torrent-ranking-author-initials
Open

feat: Configurable minimum-score threshold (+ fix for ranking authors with initials)#235
NichCodes wants to merge 2 commits into
kikootwo:mainfrom
NichCodes:fix/torrent-ranking-author-initials

Conversation

@NichCodes

@NichCodes NichCodes commented Jun 23, 2026

Copy link
Copy Markdown

Fix torrent ranking for authors with initials; make the minimum-score threshold configurable

Problem

  1. The ranking algorithm's author-presence gate could not reconcile compacted
    initials ("JRR Tolkien") with spaced initials ("J R R Tolkien"). Because that gate
    hard-zeros the entire 60-point title/author match when the author isn't found,
    correct, well-seeded releases were scored far below the accept threshold and
    rejected — leaving requests stuck in awaiting_search. It affected any
    initials-style author (JD Robb / J D Robb, George RR Martin / George R R Martin,
    W E B Griffin, etc.).
  2. The automatic-search accept threshold was hard-coded, so the only way to make
    it stricter or more lenient was a code change. Different setups need different
    bars (a single high-quality indexer vs. many noisy public ones).
image

Fix

  • Add an initials-normalization step (collapseInitials) that joins runs of
    single-letter tokens, applied in checkAuthorPresenceWithParsed and the
    Stage-3 author substring scoring so spaced and compacted initials compare
    equal.

  • Make the accept threshold admin-configurable instead of a hard-coded number.
    Two optional sliders on Settings → Indexers (styled like the Indexer Flag
    Configuration section, marked Optional):

    • Audiobooks → config key indexer.min_quality_score
    • E-books → config key indexer.min_quality_score_ebook

    Each ranges 0–100, default 50, with inline help explaining the trade-offs
    (too high rejects everything and stalls requests in awaiting_search; too low
    grabs weaker matches) and a warning when set to 0. The title/author match
    gate (matchScore > 0) still applies independently, so even at 0 a wrong
    title/author is rejected. Manual/interactive searches remain unfiltered.
    The search processors read these keys at runtime (clamped 0–100; missing/invalid
    → 50).

  • For e-books, the same change also adds the title/author match gate
    (matchScore > 0) the audiobook path already had, so a wrong-author release can
    no longer slip through on size/seeder/format score alone.

  • The clamp/default logic is centralized in one helper
    (parseMinQualityScore / DEFAULT_MIN_QUALITY_SCORE) shared by all four read
    sites, since the settings GET, the indexer-options route, and both processors
    must interpret the keys identically.

Tests

  • Regression coverage for ranking: the initials variants and a
    wrong-author negative to confirm the gate still rejects mismatches.
  • Processor + settings coverage: search-indexers / search-ebook honor the
    configured threshold (default 50) and the match gate; indexer-options persists
    and validates the new keys (integer 0–100); settings save sends them.

Scope

  • src/lib/utils/ranking-algorithm.ts — initials normalization
  • src/lib/processors/search-indexers.processor.ts,
    src/lib/processors/search-ebook.processor.ts — read configurable threshold
  • src/lib/utils/min-quality-score.ts — shared parse/clamp helper + default
  • src/components/admin/MinScoreSlider.tsx — new slider component
  • src/app/admin/settings/tabs/IndexersTab/IndexersTab.tsx,
    src/app/admin/settings/lib/{types,helpers}.ts — UI + wiring
  • src/app/api/admin/settings/route.ts,
    src/app/api/admin/settings/indexer-options/route.ts — load/save/validate
  • Docs: documentation/settings-pages.md, documentation/phase3/ranking-algorithm.md,
    documentation/TABLEOFCONTENTS.md
  • Ranking test file + processor/helpers tests

The torrent ranking author-presence gate could not reconcile compacted
initials ("TJ Klune") with spaced initials ("T J Klune"), which zeroed the
entire title/author match score and rejected otherwise-correct, well-seeded
releases. This affected any initials-style author (JD Robb / J D Robb,
George RR Martin / George R R Martin, etc.).

- Add an initials-normalization step (collapseInitials) applied in the
  author-presence check and Stage 3 author scoring so spaced and compacted
  initials compare equal.
- Lower the accept threshold 50 -> 40 for single high-quality-indexer
  setups, guarded by a match-score requirement (matchScore > 0) so the
  relaxed bar still cannot admit a wrong book.

Adds regression tests covering the initials variants and a wrong-author
negative case.
…arches

Replace the hard-coded auto-search accept threshold with admin-configurable,
per-media minimum ranking-score sliders on the Indexers settings tab.

- Two optional sliders (Audiobooks, E-books), range 0-100, default 50, styled
  to match the Indexer Flag Configuration section and marked Optional.
- Backed by config keys `indexer.min_quality_score` and
  `indexer.min_quality_score_ebook`; loaded via the settings GET, validated and
  persisted (integers 0-100) via the indexer-options route.
- search-indexers and search-ebook processors read the configured threshold at
  runtime (clamped 0-100; missing/invalid -> 50). The title/author match gate
  (matchScore > 0) is preserved and applied independently, so a value of 0 still
  rejects wrong books. Manual/interactive searches remain unfiltered.
- Default audiobook threshold returns to 50 (was temporarily lowered to 40),
  now overridable instead of pinned in code.
- Extract a single parseMinQualityScore/DEFAULT_MIN_QUALITY_SCORE helper so the
  four read sites that must stay in lock-step share one implementation.
- Update settings, ranking-algorithm, and table-of-contents docs.
@NichCodes NichCodes changed the title Fix torrent ranking for authors with initials; make the minimum-score threshold configurable feat: Configurable minimum-score threshold (+ fix for ranking authors with initials) Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant