From eed2c28aa82efd54d809d3c2c5131347c2a3235e Mon Sep 17 00:00:00 2001 From: Jack Yao <105488074+StarsExpress@users.noreply.github.com> Date: Tue, 27 Oct 2026 09:22:29 -0400 Subject: [PATCH 1/2] Fixed threshold not resetting when returning to ongoing season. Co-Authored-By: Claude --- frontend/data.js | 10 ++++++++++ frontend/filters.js | 4 ++-- frontend/main.js | 29 +++++++++++++++++------------ playbook/architecture/THRESHOLDS.md | 12 +++++++++--- playbook/tests/TEST_FILTERS.md | 4 ++-- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/frontend/data.js b/frontend/data.js index 83939f0..90ce222 100644 --- a/frontend/data.js +++ b/frontend/data.js @@ -113,6 +113,16 @@ export function currentCategoryMeta() { return metadata[els.category.value]; } +// True when switching between these two seasons changes the category's default +// threshold — an ongoing season (DYNAMIC_THRESHOLDS) against a finalized one +// (DEFAULT_THRESHOLDS), in either direction. Two finalized seasons share one +// static default, so the user's value stays. Reads the default each season +// carries in /api/metadata, so it follows whatever config.py resolved. +export function seasonSwitchChangesThresholdDefault(fromSeason, toSeason) { + const defaults = currentCategoryMeta().default_thresholds; + return defaults[fromSeason] !== defaults[toSeason]; +} + // True for whatever season is still in progress this calendar year, false // for every finalized/historical one — same Calendar Year comparison // config.py's resolve_default_threshold() routes the static-vs-dynamic diff --git a/frontend/filters.js b/frontend/filters.js index 722e9be..1ba42cd 100644 --- a/frontend/filters.js +++ b/frontend/filters.js @@ -777,7 +777,7 @@ export async function updatePlayerPool() { // reassigns .max/.value, checked in priority order below: // // 1. resetThresholdOnNextRange is still true — a Category switch or an -// ongoing→historical Season switch is still pending. A Category switch +// ongoing↔historical Season switch is still pending. A Category switch // already ran resetThresholdToCategoryDefault() synchronously (a rough // placeholder — it can only grow .max just far enough to fit the new // default off whatever pending data was already on hand, not this @@ -873,7 +873,7 @@ export function updateThresholdRange() { resetThresholdOnNextRange = false; } else if (Number(els.threshold.value) > max) { // Every other Season/Position change (Position always; Season only - // when it isn't an ongoing→historical transition — main.js's season + // when it isn't an ongoing↔historical transition — main.js's season // "change" handler already forces resetThresholdOnNextRange for that // case via resetThresholdToCategoryDefault(), so this branch won't even // run for it) — keep the user's value if it still fits; otherwise fall diff --git a/frontend/main.js b/frontend/main.js index 7e992b6..c889974 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -12,7 +12,7 @@ import { setPlayerPool, setAppliedFilters, preloadLogos, - isOngoingSeason, + seasonSwitchChangesThresholdDefault, currentCategoryMeta, metadata, } from "./data.js"; @@ -66,8 +66,9 @@ import { // Tracks whatever Season value was last settled (either by the user picking // one, or a category switch's own season-select rebuild) so the season -// "change" handler below can tell an ongoing→historical transition apart -// from every other one — a plain els.season.value read inside that handler +// "change" handler below can tell a switch that changes the threshold default +// (ongoing↔historical) apart from every other one — a plain +// els.season.value read inside that handler // only ever sees the *new* value, never what it was a moment ago. Synced // in three places: right after the initial load, at the end of a category // switch (which can silently rebuild/reset the season