website refactor
This commit is contained in:
@@ -35,10 +35,16 @@ export class LeagueDetailViewDataBuilder {
|
||||
|
||||
// Calculate info data
|
||||
const membersCount = Array.isArray(memberships.members) ? memberships.members.length : 0;
|
||||
const completedRacesCount = races.filter(r => (r as any).status === 'completed').length;
|
||||
const completedRacesCount = races.filter(r => {
|
||||
const status = (r as any).status;
|
||||
return status === 'completed' || status === 'past';
|
||||
}).length;
|
||||
|
||||
// Compute real avgSOF from races
|
||||
const racesWithSOF = races.filter(r => typeof (r as any).strengthOfField === 'number' && (r as any).strengthOfField > 0);
|
||||
const racesWithSOF = races.filter(r => {
|
||||
const sof = (r as any).strengthOfField;
|
||||
return typeof sof === 'number' && sof > 0;
|
||||
});
|
||||
const avgSOF = racesWithSOF.length > 0
|
||||
? Math.round(racesWithSOF.reduce((sum, r) => sum + ((r as any).strengthOfField || 0), 0) / racesWithSOF.length)
|
||||
: null;
|
||||
|
||||
Reference in New Issue
Block a user