/* Helper functions to find the Person for RegisterUpdaters */ func findPerson(k string) *Person { ids := statemanager.ParseIDs(k) id := ids[0] p, ok := persons[id] if !ok { p = blankPerson(id) persons[id] = p } return p }
/* Helper functions to find the League for RegisterUpdaters */ func findLeague(k string) *League { ids := statemanager.ParseIDs(k) id := ids[0] l, ok := leagues[id] if !ok { l = blankLeague(id) leagues[id] = l } return l }
/* Helper functions to find the skater for RegisterUpdaters */ func (t *team) findSkater(k string) *skater { ids := statemanager.ParseIDs(k) if len(ids) < 2 { return nil } id := ids[1] s, ok := t.skaters[id] if !ok { s = blankSkater(t, id) t.skaters[id] = s } return s }
/* Helper functions to find the stateSnapshot for RegisterUpdaters */ func (sb *Scoreboard) findStateSnapshot(k string) *stateSnapshot { ids := statemanager.ParseIDs(k) if len(ids) == 0 { return nil } id, err := strconv.ParseInt(ids[0], 10, 64) if err != nil { return nil } // Generate blank snapshots if needed for i := int64(len(sb.snapshots)); i <= id; i++ { sb.snapshots = append(sb.snapshots, blankStateSnapshot(sb, i)) } return sb.snapshots[id] }
/* helper functions to find the jam for registerupdaters */ func (sb *Scoreboard) findJam(k string) *jam { ids := statemanager.ParseIDs(k) if len(ids) == 0 { return nil } id, err := strconv.ParseInt(ids[0], 10, 64) if err != nil { return nil } // generate blank snapshots if needed for i := int64(len(sb.jams)); i <= id; i++ { sb.jams = append(sb.jams, blankJam(sb)) } return sb.jams[id] }
/* Helper functions to find the jam for RegisterUpdaters */ func (s *skater) findBoxTrip(k string) *boxTrip { ids := statemanager.ParseIDs(k) if len(ids) == 0 { return nil } id, err := strconv.ParseInt(ids[0], 10, 64) if err != nil { return nil } // Generate blank snapshots if needed for i := int64(len(s.boxTrips)); i <= id; i++ { s.boxTrips = append(s.boxTrips, blankBoxTrip(s)) } return s.boxTrips[id] }