Session 43: Data pipeline + audit fixes + depth chart foundation (2045 tests)
P0 fixes + wiring real data into the S42 Player Intelligence architecture. - P0 dropdown z-index: the nav's backdrop-filter stacking context let the Ticker/HeartbeatBar paint over the avatar/More dropdowns and eat clicks. nav now position:relative zIndex:2; menus zIndex:100. Avatar Settings -> /settings. - Real MLB stats: mlbStatsAdapter.searchPlayer + getPlayerStats (name->id-> season+gamelog). playerIntelService.resolvePlayerStats normalizes into the archetype classifier; getPlayerIntel returns found:true + real season + archetype classified from real stats. NBA via nbaStatsClient (degrades). - Game cards: slateAdapter.groupPropsByPlayer (playerStrips, name once) + mapPitchers (MLB probables), folded into mapScheduleToGameCards. Legacy GameCard line grid renders BookChip (brand colors) not grey text. - Grade card intel: analyzeViaEngine1.buildIntelFields computes stat-context + form/usage/matchup/rest from the existing feature vector (zero extra I/O); gradeAdapter lights up the card sections. Archetype deferred (needs season line at grade time). - Depth chart foundation: depthChartService (getLineup/getDepthChart/ getCascadeProjection) + /api/stats/lineup|depth|cascade, graceful + injectable. - Mobile: player hero name overflow-wrap + 24px on <=640px (was clipping). Backend 2011 -> 2045 tests (+34), 163 suites. Web build clean (exit 0). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
// Session 43 — slate adapter: player-grouped strips + MLB pitchers + BookChip.
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const WEB = path.join(__dirname, '..', '..', 'web', 'src');
|
||||
const adapter = require('../../web/src/lib/slateAdapter');
|
||||
|
||||
describe('groupPropsByPlayer', () => {
|
||||
it('groups props so each player appears once (name not repeated)', () => {
|
||||
const out = adapter.groupPropsByPlayer([
|
||||
{ player: 'Austin Riley', team: 'ATL', stat: 'Hits', line: 1.5, side: 'Over', grade: 'A' },
|
||||
{ player: 'Austin Riley', team: 'ATL', stat: 'Total Bases', line: 1.5, side: 'Over', grade: 'B+' },
|
||||
{ player: 'Bryce Harper', team: 'PHI', stat: 'TB', line: 1.5, side: 'Over', grade: 'A' },
|
||||
]);
|
||||
expect(out).toHaveLength(2);
|
||||
expect(out[0].player).toBe('Austin Riley');
|
||||
expect(out[0].props).toHaveLength(2);
|
||||
expect(out[0].props[0].side).toBe('O');
|
||||
expect(out[1].player).toBe('Bryce Harper');
|
||||
});
|
||||
|
||||
it('attaches an archetype when a lookup is provided', () => {
|
||||
const out = adapter.groupPropsByPlayer(
|
||||
[{ player: 'Riley', stat: 'Hits', line: 1.5, side: 'Over', grade: 'A' }],
|
||||
() => ({ primary: 'POWER PULL' }),
|
||||
);
|
||||
expect(out[0].archetype).toEqual({ primary: 'POWER PULL' });
|
||||
});
|
||||
|
||||
it('returns [] for empty / non-array input', () => {
|
||||
expect(adapter.groupPropsByPlayer(null)).toEqual([]);
|
||||
expect(adapter.groupPropsByPlayer([])).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mapPitchers', () => {
|
||||
it('maps MLB probable pitchers to the GameCard shape', () => {
|
||||
const p = adapter.mapPitchers({
|
||||
sport: 'mlb',
|
||||
away: { probablePitcher: { name: 'Spencer Strider' } },
|
||||
home: { probablePitcher: { name: 'Zack Wheeler' } },
|
||||
awayPitcherERA: 3.21, homePitcherERA: 2.89,
|
||||
});
|
||||
expect(p.away.name).toBe('Spencer Strider');
|
||||
expect(p.away.era).toBe('3.21');
|
||||
expect(p.home.name).toBe('Zack Wheeler');
|
||||
});
|
||||
it('returns undefined for non-MLB or no probables', () => {
|
||||
expect(adapter.mapPitchers({ sport: 'nba' })).toBeUndefined();
|
||||
expect(adapter.mapPitchers({ sport: 'mlb' })).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('mapScheduleToGameCards includes the new fields', () => {
|
||||
it('builds playerStrips + pitchers on each card', () => {
|
||||
const cards = adapter.mapScheduleToGameCards(
|
||||
[{ id: 'ATL-PHI', sport: 'mlb', awayTeam: { abbreviation: 'ATL', name: 'Braves' }, homeTeam: { abbreviation: 'PHI', name: 'Phillies' }, away: { probablePitcher: { name: 'Strider' } }, home: { probablePitcher: { name: 'Wheeler' } } }],
|
||||
{},
|
||||
[],
|
||||
[{ player: 'Austin Riley', team: 'ATL', stat: 'Hits', line: 1.5, grade: 'A', side: 'Over' }],
|
||||
);
|
||||
expect(cards[0].playerStrips[0].player).toBe('Austin Riley');
|
||||
expect(cards[0].pitchers.away.name).toBe('Strider');
|
||||
});
|
||||
});
|
||||
|
||||
describe('legacy GameCard uses BookChip (brand colors)', () => {
|
||||
it('renders book chips instead of plain grey text', () => {
|
||||
const src = fs.readFileSync(path.join(WEB, 'components', 'GameCard.tsx'), 'utf8');
|
||||
expect(src).toContain('BookChip');
|
||||
expect(src).toContain('book={r.book}');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user