Wave 2A: real player headshots — sport-agnostic id threaded from ingestion
Threads a REAL athlete id from the snapshot's per-player stats resolve (zero
new I/O) → enriched grade → grades:{sport} → slate strip → PlayerAvatar. Real
photo where an id resolves; team-colored monogram (never a gray silhouette,
never a broken image) where it can't. Ids are never fabricated.
Ingestion (Addition 1):
- espnStatsAdapter.getSeasonAverages now RETURNS the resolved ESPN athlete id
(was discarded) as espnId; non-numeric uid degrades to null.
- playerIntelService surfaces MLBAM playerId (MLB) / ESPN espnId (NBA/WNBA).
- snapshotService captures both per player and stores them on the enriched
grade beside archetype/team (null when unresolved → monogram path).
Thread → component:
- slateAdapter.buildPlayerStripsFromProps carries playerId/espnId onto each
strip; StatStrip → PlayerAvatar (accepts both ids; getHeadshotUrl routes by
sport: MLB→mlbstatic, NBA/WNBA→a.espncdn).
- Silhouette surfaces rewired to PlayerAvatar (branded monogram on null):
scan search dropdown (guarded MLBAM p.id) + tonight chips, SearchModal,
HotListPanel, GradeResultCard header. Scan grade card feeds the picked
MLBAM id through gradeAdapter.
- playerHeadshot pure URL logic extracted to CommonJS playerHeadshotUrl.js
(unit-testable; the .ts re-exports it). nfl/nhl added to ESPN_SPORT_PATH.
Tests: tests/unit/headshotThread.test.js (per-league URL + id thread + monogram
null path) + extended snapshotService/espnStatsAdapter suites. Full suite
241 suites / 2915 green; next build exit 0.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -40,6 +40,20 @@ describe('getSeasonAverages (injected http)', () => {
|
||||
expect(r.found).toBe(true);
|
||||
expect(r.team).toBe('DAL');
|
||||
expect(r.classifierInput.ppg).toBe(33);
|
||||
// Wave 2A — the REAL ESPN athlete id is surfaced (headshot CDN), not discarded.
|
||||
expect(r.espnId).toBe('123');
|
||||
});
|
||||
|
||||
it('Wave 2A — a non-numeric uid degrades espnId to null (never fabricated)', async () => {
|
||||
const http = {
|
||||
get: async (url) => {
|
||||
if (url.includes('/search')) return { data: { items: [{ uid: 's:40~l:46~a:999', displayName: 'X', team: {}, position: {} }] } };
|
||||
return { data: { statistics: { splits: { categories: [{ stats: [{ name: 'avgPoints', value: 10 }] }] } } } };
|
||||
},
|
||||
};
|
||||
const r = await espn.getSeasonAverages('X', 'nba', { http });
|
||||
expect(r.found).toBe(true);
|
||||
expect(r.espnId).toBeNull();
|
||||
});
|
||||
|
||||
it('degrades to found:false when ESPN errors', async () => {
|
||||
@@ -56,11 +70,13 @@ describe('resolvePlayerStats wires the ESPN fallback for NBA', () => {
|
||||
it('falls back to ESPN when nbaStatsClient is offline → classifies', async () => {
|
||||
const r = await svc.resolvePlayerStats('Luka Doncic', 'nba', {
|
||||
nbaClient: { getSeasonAvg: async () => { throw new Error('python offline'); } },
|
||||
espnStats: { getSeasonAverages: async () => ({ found: true, team: 'DAL', position: 'G', classifierInput: { ppg: 33, apg: 9, rpg: 8 } }) },
|
||||
espnStats: { getSeasonAverages: async () => ({ found: true, team: 'DAL', position: 'G', classifierInput: { ppg: 33, apg: 9, rpg: 8 }, espnId: '3945274' }) },
|
||||
});
|
||||
expect(r.found).toBe(true);
|
||||
expect(r.team).toBe('DAL');
|
||||
expect(r.classifierInput.ppg).toBe(33);
|
||||
// Wave 2A — espnId surfaces through resolvePlayerStats → the snapshot grade.
|
||||
expect(r.espnId).toBe('3945274');
|
||||
});
|
||||
|
||||
it('found:false when both sources are empty', async () => {
|
||||
|
||||
Reference in New Issue
Block a user