/** * Import landing summary data and update game stats, ensuring robust empty-net goal detection. * * @param int $game_id * @param array $landing_data * @return bool */ function otg_import_landing_summary($game_id, $landing_data) { global $wpdb; $table_goals = $wpdb->prefix . 'otg_game_goals'; if (empty($landing_data) || !isset($landing_data['summary']['scoring'])) { return false; } $scoring_periods = $landing_data['summary']['scoring']; foreach ($scoring_periods as $period) { if (empty($period['goals'])) { continue; } foreach ($period['goals'] as $goal) { $goal_id = intval($goal['eventId'] ?? 0); $goal_modifier = sanitize_text_field($goal['goalModifier'] ?? ''); $landing_modifier = sanitize_text_field($goal['landingModifier'] ?? ''); // Robust direct empty net evaluation using the official API goal node properties $is_empty_net = 0; if (isset($goal['emptyNet']) && $goal['emptyNet'] === true) { $is_empty_net = 1; } elseif (in_array(strtolower($goal_modifier), ['empty-net', 'en', 'empty-net-goal'], true) || in_array(strtolower($landing_modifier), ['empty-net', 'en', 'empty-net-goal'], true)) { $is_empty_net = 1; } // Update database record for the specific goal event $wpdb->update( $table_goals, ['is_empty_net' => $is_empty_net], [ 'game_id' => $game_id, 'goal_id' => $goal_id ], ['%d'], ['%d', '%d'] ); } } return true; } /** * Backfill season empty-net goals using play-by-play data payloads. * * @param int $season * @return void */ function otg_backfill_season_empty_net_goals($season) { global $wpdb; $table_goals = $wpdb->prefix . 'otg_game_goals'; $table_games = $wpdb->prefix . 'otg_games'; // Retrieve completed games for the designated season $games = $wpdb->get_results($wpdb->prepare( "SELECT game_id, pbp_json FROM $table_games WHERE season = %d AND status = 'OFF'", $season )); foreach ($games as $game) { $game_id = intval($game->game_id); $pbp_data = json_decode($game->pbp_json, true); if (empty($pbp_data) || !isset($pbp_data['plays'])) { continue; } foreach ($pbp_data['plays'] as $play) { if (($play['typeCode'] ?? 0) !== 505) { // 505 represents a goal event in the NHL API continue; } $details = $play['details'] ?? []; $goal_id = intval($play['eventId'] ?? 0); $is_empty_net = false; if (!empty($details['emptyNet']) && $details['emptyNet'] === true) { $is_empty_net = true; } elseif (in_array(strtolower($play['goalModifier'] ?? ''), ['empty-net', 'en', 'empty-net-goal'], true)) { $is_empty_net = true; } if ($is_empty_net) { $wpdb->update( $table_goals, ['is_empty_net' => 1], [ 'game_id' => $game_id, 'goal_id' => $goal_id ], ['%d'], ['%d', '%d'] ); } } } } CuyllRanger – Activity – OutsideTheGarden Boards – Page 63
JULY
«
Sun
25
Mon
26
Tue
27
Wed
28
Thu
29
Fri
30
Sat
31
»
CuyllRanger
CuyllRanger
Group: Registered
Joined: 2024-12-02
Hall of Famer
3
Follow
Schneider should be moved up the lineup. Time to see if he c...

In forum Where Smit Hits The Fan

1 year ago
Must win? Gotta keep Ottawa in the sights.

In forum Where Smit Hits The Fan

1 year ago
I agree about Lafreniere I don’t see a problem moving him an...

In forum Where Smit Hits The Fan

1 year ago
Cuylle contract.

In forum Where Smit Hits The Fan

1 year ago
Had to get two points. Minny can have one doesn’t hurt the ...

In forum Where Smit Hits The Fan

1 year ago
. and Vaakaneinen played him loose.

In forum Where Smit Hits The Fan

1 year ago
Rangers lol it’s always sumpthin .

In forum Where Smit Hits The Fan

1 year ago
Johnny gives you what he’s got every game .

In forum Where Smit Hits The Fan

1 year ago
Would it be that bad a idea to start the second PP unit?

In forum Where Smit Hits The Fan

1 year ago
Almost like watching paint dry.

In forum Where Smit Hits The Fan

1 year ago
Its always sumpthin.

In forum Where Smit Hits The Fan

1 year ago
Lafreniere fifth season and how many games on his natural wi...

In forum Where Smit Hits The Fan

1 year ago
Its a combination of coaches getting their point across in a...

In forum Where Smit Hits The Fan

1 year ago
The Rangers have traded Trouba, Kakko, Chytil, Mancini, and...

In forum Where Smit Hits The Fan

1 year ago
The Rangers continually make mistakes and choices on defense...

In forum Where Smit Hits The Fan

1 year ago
Page 63 / 213