Fix multi-circuit events not showing all matching circuit tags
BCP's leagueId query only matches an event's primary league, not every league in its own `leagues` array, so an event belonging to a second watched circuit (e.g. Show Me Showdown under both LMC 2027 and Warhammer Global Rankings 2026) never got tagged with the circuit whose query never returned it. Cross-reference ev.leagues against CONFIG.circuits to pick up those additional memberships. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -325,6 +325,23 @@ function mergeEvents(results) {
|
||||
byId.get(ev.id).circuits.push(circuit);
|
||||
}
|
||||
}
|
||||
// BCP's leagueId query only matches an event's single primary/owning
|
||||
// league, not every league in the event's own `leagues` array — so an
|
||||
// event can belong to a second watched circuit whose dedicated fetch
|
||||
// never returns it. Cross-reference ev.leagues against CONFIG.circuits
|
||||
// to pick up those additional memberships (still honoring `near`, since
|
||||
// this bypasses the radius filter applied in load()).
|
||||
for (const { event: ev, circuits } of byId.values()) {
|
||||
const already = new Set(circuits.map(c => c.id));
|
||||
for (const league of ev.leagues || []) {
|
||||
if (already.has(league.id)) continue;
|
||||
const circuit = CONFIG.circuits.find(c => c.id === league.id);
|
||||
if (circuit && withinRadius(ev, circuit.near)) {
|
||||
circuits.push(circuit);
|
||||
already.add(circuit.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return [...byId.values()].sort((a, b) => Date.parse(a.event.eventDate) - Date.parse(b.event.eventDate));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user