StatsPerformNrlScoreboardImporter¶
Manually triggers a full reprocess of an NRL match scoreboard from StatsPerform. Fetches live match data from the StatsPerform API, resolves player and team ID mappings, and generates domain commands to update scores, the match clock, lineups, and participant stats.
This importer performs the same work as the automated Timer 2 polling in StatsPerformNrlScoreboardTimerService, but can be triggered on demand via the UI "Reprocess" button or the import API. Both paths share the StatsPerformNrlScoreboardMapper and resolve IDs through the same IEntityMappingService.
Importer Details¶
| Property | Value |
|---|---|
| Importer Name | StatsPerformNrlScoreboard |
| Data Contract | StatsPerformNrlScoreboardImport |
| Module | StatsPerformNrl |
| Authorization | Requires authenticated user (ContentManager or Admin for UI) |
| Commands Generated | SetRugbyLeagueScoreCommand (optional), SetRugbyLeagueMatchClockCommand (always), SetRugbyLeagueLineupCommand (optional), SetRugbyLeagueParticipantStatsCommand (optional) |
Input Contract¶
| Field | Type | Required | Description |
|---|---|---|---|
SportingEventId |
Guid |
Yes | The LuckBox sporting event ID (fixture) to reprocess |
Behaviour¶
- Resolves the StatsPerform game ID for the fixture by calling
IEntityMappingService.ResolveProviderIdAsync<SportingEventId>(SportsDataProviders.StatsPerform, sportingEventId)and parsing the result as along. - If no mapping exists (or the provider ID is not a valid number), logs a warning and returns no commands.
- Loads all player and team mappings for the StatsPerform provider via
ResolveAllForProviderAsync<ParticipantId>andResolveAllForProviderAsync<TeamId>, parses their integer source keys, and packages them into aStatsPerformIdMappingsholder. - Fetches full match stats and events from the StatsPerform API via
StatsPerformNrlApi.GetMatchStatsAndEventsAsync. - Logs any unmapped player or team IDs via
StatsPerformNrlScoreboardMapper.LogUnmappedIds(these fall back to deterministic IDs that will not match existing aggregates). - Generates up to four domain commands - always reprocessing everything:
SetRugbyLeagueScoreCommand(added when non-null) - Updates match score and per-period breakdowns.SetRugbyLeagueMatchClockCommand(always added) - Sets the match-level and per-period clocks from StatsPerformgameSeconds/ elapsed-time fields.SetRugbyLeagueLineupCommand(added when non-null - requires team and player data) - Updates team lineups.SetRugbyLeagueParticipantStatsCommand(added when non-null - requires team and player data) - Updates individual player statistics.
ID Resolution¶
ID resolution is delegated to IEntityMappingService (resolved from LBS.Domain.Infrastructure.ClickHouse), which is injected into the importer. There is no hardcoded fixture or team dictionary - all mappings live behind the crosswalk that the service queries.
| Entity | Service call | Direction |
|---|---|---|
| Fixture / game | ResolveProviderIdAsync<SportingEventId>(SportsDataProviders.StatsPerform, sportingEventId) |
LuckBox SportingEventId -> StatsPerform game ID (string, parsed to long) |
| Players | ResolveAllForProviderAsync<ParticipantId>(SportsDataProviders.StatsPerform) |
StatsPerform source ID (string) -> ParticipantId |
| Teams | ResolveAllForProviderAsync<TeamId>(SportsDataProviders.StatsPerform) |
StatsPerform source ID (string) -> TeamId |
The player and team results are returned keyed by their string source IDs. The importer parses each key to an int and builds the two dictionaries that back StatsPerformIdMappings (PlayerIds and TeamIds). Team keys that are not valid integers are logged and skipped.
When a StatsPerform player or team ID has no crosswalk entry, the mapper falls back to a deterministic ID derived from the source ID (ParticipantId.From(playerId, ...) / TeamId.From(teamId, ...)). These deterministic IDs will not match existing aggregates, so LogUnmappedIds emits a warning for every unmapped entity to aid debugging.
Mapping Holder¶
StatsPerformIdMappings is a plain holder constructed in the importer and passed to the mapper methods. It exposes two read-only dictionaries:
| Property | Type | Description |
|---|---|---|
PlayerIds |
IReadOnlyDictionary<int, ParticipantId> |
StatsPerform integer player ID -> ParticipantId |
TeamIds |
IReadOnlyDictionary<int, TeamId> |
StatsPerform integer team ID -> TeamId |
API Examples¶
Reprocess a match via API¶
POST /api/import
Authorization: Bearer <token>
Content-Type: application/json
{
"importerType": "StatsPerformNrlScoreboard",
"priority": "High",
"importData": {
"sportingEventId": "5d285b3c-6e4d-52a6-b2a2-664b08e61615"
}
}
Response¶
{
"jobId": "550e8400-e29b-41d4-a716-446655440000",
"status": "Pending",
"message": "Import job queued successfully"
}
Via SDK (TypeScript)¶
import { sportImports } from '@luckboxstudios/foundry-sdk/sport';
const result = await client.import(
'StatsPerformNrlScoreboard',
sportImports.statsPerformNrlScoreboard({ sportingEventId: '5d285b3c-6e4d-52a6-b2a2-664b08e61615' })
);
UI Integration¶
A "Reprocess" button is available on the Rugby League Scoreboard tab (rugby-league-scoreboard.svelte) for users with the ContentManager or Admin role. The button:
- Calls the
StatsPerformNrlScoreboardimporter viaauthStore.client.import() - Shows a spinning icon during processing
- Displays a "Reprocess Queued" badge on success (auto-dismisses after 5 seconds)
- Displays an error badge if the import fails
Related Files¶
| File | Description |
|---|---|
src/Integration/LBS.Fantasy.Integration/Importers/StatsPerform/League/StatsPerformNrlScoreboardImporter.cs |
Importer implementation; resolves IDs via IEntityMappingService and emits the commands |
src/Integration/LBS.Fantasy.Integration/Importers/StatsPerform/League/StatsPerformNrlScoreboardImporterData.cs |
Import data contract |
src/Integration/LBS.Fantasy.Integration/Importers/StatsPerform/League/StatsPerformNrlScoreboardMapper.cs |
Maps StatsPerform data to domain commands (score, match clock, lineup, participant stats) |
src/Integration/LBS.Fantasy.Integration/Importers/StatsPerform/League/StatsPerformIdMappings.cs |
Holder for the resolved StatsPerform player and team ID dictionaries |
src/Integration/LBS.Fantasy.Integration/Importers/StatsPerform/League/StatsPerformNrlScoreboardTimerService.cs |
Automated polling service (Timer 1 + Timer 2) |
src/Domain/LBS.Domain.Infrastructure/ClickHouse/IEntityMappingService.cs |
Entity crosswalk service used for all StatsPerform ID resolution |
src/Domain/LBS.Domain.Sport/SportsDataProviders.cs |
Defines SportsDataProviders.StatsPerform, the provider key used for resolution |
src/Domain/LBS.Domain.Sport/Scoreboard/Commands/RugbyLeague/SetRugbyLeagueMatchClockCommand.cs |
Command applied for the always-emitted match clock |
src/Apps/foundry-web/src/lib/components/rugby-league/rugby-league-scoreboard.svelte |
UI reprocess button |
docs/importers/statsperform-nrl-match-state-reference.md |
Stats Perform game state model, Foundry mappings, polling rates, and state transitions |