Find every gamelog entry plausibly matching a leg's bet date. Used by
the watcher to detect doubleheader-style ambiguity (MLB primarily).
Window: ±opts.window around legGameDateHint (defaults to
GAMELOG_WINDOW_MS = ±36h). The watcher tightens to ±12h when a leg's
linkage.gameStartsAt is known so a futures-style placed_at can't
pull in the wrong day's gamelog entry. Sort: forward-bias (entries
after the hint come first, since users place bets before tipoff),
then by absolute proximity. The forward-bias matters when a player
has back-to-back games — the upcoming one is the bet target, the
just-played one is just chronologically close.
Ambiguity rule: if the top two candidates are within
GAMELOG_AMBIGUITY_MS of each other (not of the dateHint), both are
returned. This catches doubleheaders where two entries land on the
same calendar date hours apart and a clean pick would be a guess.
Return semantics:
[] → no entry in window (game hasn't been played yet,
or legGameDateHint is null/unparseable without
opts.assumeFirst: true)
[a] → unambiguous match
[a, b] → ambiguous; caller should defer or surface picker
v0.2 fix: previously, a null or unparseable legGameDateHint returned
[entries[0]] — silently picking the first entry. That's the WRONG
choice for doubleheaders (entries are typically sorted descending by
date, so "first" = most recent, but a bet placed for tonight should
match tonight's game, not last night's). The new default is [].
Pass { assumeFirst: true } to opt into the legacy behavior.
Find every gamelog entry plausibly matching a leg's bet date. Used by the watcher to detect doubleheader-style ambiguity (MLB primarily).
Window: ±
opts.windowaroundlegGameDateHint(defaults to GAMELOG_WINDOW_MS = ±36h). The watcher tightens to ±12h when a leg'slinkage.gameStartsAtis known so a futures-style placed_at can't pull in the wrong day's gamelog entry. Sort: forward-bias (entries after the hint come first, since users place bets before tipoff), then by absolute proximity. The forward-bias matters when a player has back-to-back games — the upcoming one is the bet target, the just-played one is just chronologically close.Ambiguity rule: if the top two candidates are within GAMELOG_AMBIGUITY_MS of each other (not of the dateHint), both are returned. This catches doubleheaders where two entries land on the same calendar date hours apart and a clean pick would be a guess.
Return semantics:
opts.assumeFirst: true)v0.2 fix: previously, a null or unparseable
legGameDateHintreturned[entries[0]]— silently picking the first entry. That's the WRONG choice for doubleheaders (entries are typically sorted descending by date, so "first" = most recent, but a bet placed for tonight should match tonight's game, not last night's). The new default is[]. Pass{ assumeFirst: true }to opt into the legacy behavior.