Session 54: Audit cleanup — name edges + polish (2255 tests)

P1 name edge cases (BOTH playerName.js copies, kept identical):
- normalizeName strips hyphens (display+key): "Jung-hoo Lee" === "Jung Hoo Lee".
- nameKey strips single-letter MIDDLE tokens: "Josh H Smith" === "Josh Smith"
  (keeps first+last; real middle names + collapsed initials untouched).
- richie -> richard added to NICKNAMES.

P2 polish:
- Team Hub names normalized at the source (teamService.getTeamHub) so
  "J.C. Escarra" renders as "JC Escarra" like the dashboard.
- snapshotService dedup keeps the highest-confidence GRADE but the richest
  DISPLAY (accented "José" over "Jose") so prop rows match the pitcher line.
- correlationWarning names the game: "2 legs from the same game (NYY @ BOS)".

Backend 2246 -> 2255 tests (+9), 194 suites. Web build clean (exit 0).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kev
2026-06-19 15:45:07 -04:00
parent b012da13f8
commit 8629021774
11 changed files with 137 additions and 12 deletions
+3 -3
View File
@@ -13,7 +13,7 @@
* Everything is injectable so the whole build is unit-testable with no network.
*/
const { nameKey } = require('../utils/playerName');
const { nameKey, normalizeName } = require('../utils/playerName');
const HUB_TTL = 15 * 60; // expensive to build; 15-min cache
const ROSTER_CONCURRENCY = 8;
@@ -83,7 +83,7 @@ async function getTeamHub(sport, abbr, opts = {}) {
const env = await cacheGet(`grades:${sp}`).catch(() => null);
const byPlayer = {};
for (const g of (env && env.grades) || []) {
const disp = g.player || g.player_name;
const disp = normalizeName(g.player || g.player_name).display || g.player || g.player_name;
const k = nameKey(disp);
if (!byPlayer[k]) byPlayer[k] = { player: disp, archetype: g.archetype ? { primary: g.archetype } : null, position: null, stats: [], props: [], propCount: 0 };
byPlayer[k].props.push({ stat: statLabel(g.stat_type || g.stat), line: g.line, side: sideChar(g.direction), grade: g.grade, gradedAt: g.gradedAt || null });
@@ -124,7 +124,7 @@ async function getTeamHub(sport, abbr, opts = {}) {
archetype = c.primary ? { primary: c.primary.name } : null;
}
return {
player: p.name,
player: normalizeName(p.name).display || p.name,
position: p.position,
jersey: p.jersey,
archetype,