Function: parse_shifts()
parse_shifts(
payload,game_id?):Row[]
Defined in: src/analytics/hockeytech.ts:184
Parse a modulekit/gameshifts payload (SiteKit.Gameshifts) into one row per
player-shift stint (py parse_shifts). The shift clock is a COUNTDOWN, so
start_s >= end_s for every row.
Parameters
payload
unknown
The raw feed body, { SiteKit: { Gameshifts: { home: [...], visitor: [...] } } }.
Anything without that envelope (null, {}, a list) yields [].
game_id?
unknown = null
Stamped verbatim into the game_id column of every row. Default null.
Returns
Row[]
One row per shift with game_id, player_id, first_name, last_name,
jersey_number, home (1 / 0: the player's own home flag, else the side he was listed
under), period (integer or null), start_time / end_time / length (raw 'MM:SS'
strings), start_s / end_s (seconds REMAINING, via mmss_to_seconds),
goal_on_shift and penalty_on_shift (integers, 0 when absent). Home players first, then
visitors, in feed order. [] for an empty game.
Throws
TypeError when home, period, goal_on_shift or penalty_on_shift is neither
a number nor an integer string (py int() semantics).
Example
import { parse_shifts } from "sportsdataverse/dist/analytics/hockeytech.js";
const rows = parse_shifts(gameshiftsPayload, 42);
rows[0].start_s >= rows[0].end_s; // true: the clock counts down
Remarks
Ids are passed through as the feed ships them (py-faithful); the network wrappers
in hockeytech_family.ts convert id columns to decimal strings on the way out.