Session 59: Addendum + work-order 1.6 + Phase 2 + Phase 3 (2352 tests)
Overnight sprint for the Saturday 10 AM ET deploy gate — day one of the
public ledger record locks against freshly posted lines.
Task A — ledger team/opponent (migration 020, applied at 0 rows):
populated in both write paths from the real feed; opponent only when the
player's team matches a game participant (never guessed). Roadmap: Phase
4.5 WNBA ESPN-boxscore settlement (due ~Jul 24) + Phase 5 per-tier
calibration logged.
Task B — work-order 1.6 CLOSED (canonical player keys):
- searchPlayer resolves via nameKey; the old matcher deleted accents
("Sanchez" with acute -> "snchez") and substring-guessed onto the WRONG
player (the mismatched last-10 bug). Ambiguous -> null, never guess.
- Slate JOIN INVARIANT: a graded prop whose player's real team isn't in
the game is dropped (TB player can't render under MIL@PIT) — locked by
tests that fail the suite on regression.
- grades:{sport} TTL 2h -> 6h (expired between 5h cron gaps — the real
cause of /team "No active props" for slate players).
Task C — Phase 2 slate UX: tabs are THE filter (URL ?sport=, deep-linkable,
duplicate legacy tablist removed); cards cap at 6 graded props sorted
A+->F with ALL N READS in-place expander; waiting states show the real
next pipeline run ("Grades post ~6:00 PM ET").
Task D — Phase 3 mobile P0: root cause of vanished 390px nav was HIDE_ON
including '/' (landing had zero navigation) — fixed; html/body overflow-x
contained; GAME LINES collapses to best-line summary + "N BOOKS" expander
below 640px; venue drops before time/pitchers ever truncate.
Live verification: raw ESPN today STILL returns the Jun 13 NYK@SA Finals
game without a date pin; the pinned fetch returns 0 games, 0 off-date.
Backend 2327 -> 2352 tests (202 suites), web build exit 0.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/* ============================================================
|
||||
Session 59 (work-order 2.3) — the REAL pipeline schedule, for honest
|
||||
waiting states. "Awaiting next scan" told the user nothing; the truth is
|
||||
the cron fires at fixed UTC hours, so we can say "Grades post ~6:00 PM ET".
|
||||
|
||||
HOURS_UTC mirrors the backend default (snapshotScheduler SNAPSHOT_HOURS_UTC
|
||||
= 14,19,22,1,3). If the env schedule changes, update BOTH places — a wrong
|
||||
time here is a lie, which is worse than the old vague copy.
|
||||
|
||||
CommonJS so the plain-JS Jest suite can require it directly.
|
||||
============================================================ */
|
||||
|
||||
const HOURS_UTC = [14, 19, 22, 1, 3];
|
||||
|
||||
/** The next scheduled run strictly after `now`, as a Date. */
|
||||
function nextRunAt(now = new Date(), hours = HOURS_UTC) {
|
||||
const candidates = [];
|
||||
for (let dayOffset = 0; dayOffset <= 1; dayOffset += 1) {
|
||||
for (const h of hours) {
|
||||
const d = new Date(now.getTime());
|
||||
d.setUTCDate(d.getUTCDate() + dayOffset);
|
||||
d.setUTCHours(h, 0, 0, 0);
|
||||
if (d.getTime() > now.getTime()) candidates.push(d);
|
||||
}
|
||||
}
|
||||
candidates.sort((a, b) => a.getTime() - b.getTime());
|
||||
return candidates[0] || null;
|
||||
}
|
||||
|
||||
/** "~6:00 PM ET" for the next run. Empty string when the schedule is unknown. */
|
||||
function nextRunLabelET(now = new Date(), hours = HOURS_UTC) {
|
||||
const next = nextRunAt(now, hours);
|
||||
if (!next) return '';
|
||||
const t = new Intl.DateTimeFormat('en-US', {
|
||||
timeZone: 'America/New_York', hour: 'numeric', minute: '2-digit',
|
||||
}).format(next);
|
||||
return `~${t} ET`;
|
||||
}
|
||||
|
||||
module.exports = { HOURS_UTC, nextRunAt, nextRunLabelET };
|
||||
@@ -241,14 +241,37 @@ function gradedAgo(iso, now = Date.now()) {
|
||||
return `${Math.round(hrs / 24)}d ago`;
|
||||
}
|
||||
|
||||
/** Team-identity match by nickname token (last word) — "New York Yankees"
|
||||
* ↔ "Yankees"; exact string match also accepted. */
|
||||
function slateTeamsMatch(a, b) {
|
||||
if (!a || !b) return false;
|
||||
const sa = String(a).toLowerCase(), sb = String(b).toLowerCase();
|
||||
if (sa === sb) return true;
|
||||
return teamMascot(a) !== '' && teamMascot(a) === teamMascot(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build pre-graded `playerStrips` for one game by OVERLAYING the snapshot's
|
||||
* locked grades onto the game's odds-derived props (which already carry the
|
||||
* correct game grouping). Each prop is either graded (grade + gradedAt + delta)
|
||||
* or `awaiting:true` (no snapshot match yet → "Awaiting next scan", no Read
|
||||
* button). Archetype comes from the snapshot's per-player classification.
|
||||
*
|
||||
* Session 59 (work-order 1.6) — THE JOIN INVARIANT: when the snapshot knows
|
||||
* the player's REAL team (grades carry `team` from the stats resolve) and
|
||||
* the caller passes the game's participants (`gameTeams`), a prop whose
|
||||
* player does NOT belong to either team is DROPPED from the card entirely —
|
||||
* a bad feed row must not render a TB player under MIL@PIT. Props without
|
||||
* team info are kept (can't verify ≠ wrong).
|
||||
*/
|
||||
function buildPlayerStripsFromProps(gameProps, gradeIndex, deltaIndex, now = Date.now()) {
|
||||
/**
|
||||
* @param {Array<object>} gameProps
|
||||
* @param {Record<string, any>} gradeIndex
|
||||
* @param {Record<string, any>} deltaIndex
|
||||
* @param {number} [now]
|
||||
* @param {{home?: string, away?: string} | null} [gameTeams]
|
||||
*/
|
||||
function buildPlayerStripsFromProps(gameProps, gradeIndex, deltaIndex, now = Date.now(), gameTeams = null) {
|
||||
const byPlayer = {};
|
||||
const order = [];
|
||||
for (const p of gameProps || []) {
|
||||
@@ -257,10 +280,16 @@ function buildPlayerStripsFromProps(gameProps, gradeIndex, deltaIndex, now = Dat
|
||||
// / "AJ Ewing") merge into ONE strip; display the longest seen variant.
|
||||
const pk = nameKey(p.player);
|
||||
const rec = gradeIndex[gradeKey(p.player, p.stat_type || p.stat)];
|
||||
// Join guard: known player team that isn't in this game → bad row, drop.
|
||||
const knownTeam = (rec && rec.team) || p.team || '';
|
||||
if (knownTeam && gameTeams && (gameTeams.home || gameTeams.away)) {
|
||||
const inGame = slateTeamsMatch(knownTeam, gameTeams.home) || slateTeamsMatch(knownTeam, gameTeams.away);
|
||||
if (!inGame) continue;
|
||||
}
|
||||
if (!byPlayer[pk]) {
|
||||
byPlayer[pk] = {
|
||||
player: displayName(p.player),
|
||||
team: p.team || '',
|
||||
team: knownTeam,
|
||||
archetype: rec && rec.archetype ? { primary: rec.archetype } : undefined,
|
||||
stats: [],
|
||||
props: [],
|
||||
|
||||
Reference in New Issue
Block a user