const E = require('./entries.json'); const S = E.filter(r => r.in_pamphlet_count && r.counted_event); const T = (rows) => ({ events: rows.length, firsts: rows.filter(r => r.first_place).length, top_three: rows.filter(r => r.top_three).length, athletes: new Set(rows.map(r => r.athlete_code)).size }); const res = {}; res.headline = [ { tally: 'Pamphlet-era snapshot (rows dated before Sept 2026)', ...T(S) }, { tally: 'HeCheated page as retrieved 2026-10-23', ...T(E.filter(r => r.counted_event)) }, ]; const codes = [...new Set(S.map(r => r.athlete_code))].sort(); res.byAthlete = codes.map(c => { const rr = S.filter(r => r.athlete_code === c); return { athlete: 'Athlete ' + c, level: [...new Set(rr.map(r => r.level))].join(' / '), sports: [...new Set(rr.map(r => r.sport))].join(' / '), years: [...new Set(rr.map(r => r.year))].sort().join(', '), ...T(rr), not_top_three: rr.length - rr.filter(r => r.top_three).length }; }); const groups = ['Regular-season meet', 'District, regional or league championship', 'State championship', 'National invitational (out of state)', 'Other or unclassified']; const fins = ['1st', '2nd-3rd', '4th-10th', '11th or lower', 'DQ or no place listed']; res.byMeetGroup = []; groups.forEach(g => fins.forEach(f => res.byMeetGroup.push({ meet_group: g, finish_group: f, entries: S.filter(r => r.meet_group === g && r.finish_group === f).length }))); res.meetGroupTotals = groups.map(g => ({ meet_group: g, ...T(S.filter(r => r.meet_group === g)) })); res.finishDistribution = fins.map(f => ({ finish_group: f, entries: S.filter(r => r.finish_group === f).length })); const scen = [ ['As counted (pamphlet snapshot)', r => true], ['Without the 1977 entry', r => r.year >= 2022], ['Only meets held in Washington', r => r.meet_location_state === 'WA'], ['Without girls\' ultimate (non-WIAA league)', r => !r.team_sport], ['Without relays and team results', r => !r.relay && !r.team_sport], ['Washington meets, 2022 or later, WIAA sports, individual events only', r => r.year >= 2022 && r.meet_location_state === 'WA' && !r.team_sport && !r.relay], ['High school only', r => r.level === 'High School'], ['Postseason only (district, regional, league or state championships)', r => /championship/i.test(r.meet_group) && r.meet_group !== 'National invitational (out of state)'], ['WIAA state meets only', r => r.wiaa_state_meet], ]; res.sensitivity = scen.map(([n, f]) => ({ scope: n, ...T(S.filter(f)) })); res.byYearLevel = []; [...new Set(S.map(r => r.year))].sort().forEach(y => ['High School', 'Middle School'].forEach(l => { const rr = S.filter(r => r.year === y && r.level === l); if (rr.length) res.byYearLevel.push({ year: y, level: l, ...T(rr) }); })); res.relays = { ...T(S.filter(r => r.relay)) }; // concentration const sorted = [...res.byAthlete].sort((a, b) => b.firsts - a.firsts); res.concentration = { top1_firsts: sorted[0].firsts, top2_firsts: sorted[0].firsts + sorted[1].firsts, total_firsts: T(S).firsts }; require('fs').writeFileSync('analyses.json', JSON.stringify(res, null, 1)); console.log(JSON.stringify(res, null, 0));