Converting game stats that are event-centric into the player centric format.
var statisticsConverter = require('podyum-stats-converter');
var actions; // event-centric json
var fieldLength; // field length in meters (integer)
var playerCentricJson = statisticsConverter.convert(actions, fieldLength);
Event-centric game statistics json format:
"actions": [
{
"defensive_team_id": <def_team_id>,
"quarter": <quarter>,
"offensive_team_id": <off_team_id>,
"events": [
{
"ball_start_position": {
"on_offensive_side": true,
"yard": 50
},
"down_number": 1,
"type": "Scrimmage",
"distance": 10
},
{
"type": "Pass",
"ball_position": {
"on_offensive_side": fakse,
"yard": 50
},
"player_id": <player_id>
}
]
}
]
Player-centric game statistics json format:
{
"player_id_1": {
"fumble_recovered": 3,
"rushing_yards": 21,
"tackles": 2,
"fumbles": 1
},
"player_id_2": {
"kickoff_attempts": 2,
"kickoff_touchbacks": 2
}
}