website refactor
This commit is contained in:
@@ -35,11 +35,11 @@ export class LeagueDetailViewDataBuilder {
|
||||
|
||||
// Calculate info data
|
||||
const membersCount = Array.isArray(memberships.members) ? memberships.members.length : 0;
|
||||
const completedRacesCount = races.filter(r => {
|
||||
const status = (r as any).status;
|
||||
return status === 'completed' || status === 'past';
|
||||
}).length;
|
||||
|
||||
|
||||
// League overview wants total races, not just completed.
|
||||
// (In seed/demo data many races are `status: running`, which should still count.)
|
||||
const racesCount = races.length;
|
||||
|
||||
// Compute real avgSOF from races
|
||||
const racesWithSOF = races.filter(r => {
|
||||
const sof = (r as any).strengthOfField;
|
||||
@@ -48,12 +48,25 @@ export class LeagueDetailViewDataBuilder {
|
||||
const avgSOF = racesWithSOF.length > 0
|
||||
? Math.round(racesWithSOF.reduce((sum, r) => sum + ((r as any).strengthOfField || 0), 0) / racesWithSOF.length)
|
||||
: null;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const race0 = races.length > 0 ? races[0] : null;
|
||||
console.info(
|
||||
'[LeagueDetailViewDataBuilder] leagueId=%s members=%d races=%d racesWithSOF=%d avgSOF=%s race0=%o',
|
||||
league.id,
|
||||
membersCount,
|
||||
racesCount,
|
||||
racesWithSOF.length,
|
||||
String(avgSOF),
|
||||
race0,
|
||||
);
|
||||
}
|
||||
|
||||
const info: LeagueInfoData = {
|
||||
name: league.name,
|
||||
description: league.description || '',
|
||||
membersCount,
|
||||
racesCount: completedRacesCount,
|
||||
racesCount,
|
||||
avgSOF,
|
||||
structure: `Solo • ${league.settings?.maxDrivers ?? 32} max`,
|
||||
scoring: scoringConfig?.scoringPresetId || 'Standard',
|
||||
|
||||
Reference in New Issue
Block a user