/** * 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'] ); } } } } Rangerjunkiekimmie – Activity – OutsideTheGarden Boards – Page 5
AUGUST
«
Tue
17
Wed
18
Thu
19
Fri
20
Sat
21
Sun
22
Mon
23
»
Rangerjunkiekimmie
Rangerjunkiekimmie
Group: Registered
Joined: 2023-08-26
NHL All Star
2
Follow
Panarin staying on the PP for the whole 2 minutes doesn't he...

In forum Where Smit Hits The Fan

10 months ago
What station is Rangers radio on?  

In forum Where Smit Hits The Fan

10 months ago
13 periods at MSG 2 goals

In forum Where Smit Hits The Fan

10 months ago
😀  

In forum Where Smit Hits The Fan

10 months ago
HEY!! That's a top 6 winger you're talking about  

In forum Where Smit Hits The Fan

10 months ago
Celebrini showing Laf what a first round draft pick should p...

In forum Where Smit Hits The Fan

10 months ago
Robertson!!!

In forum Where Smit Hits The Fan

10 months ago
Rempe with a penalty??? Didn't see it

In forum Where Smit Hits The Fan

10 months ago
  Haha  

In forum Where Smit Hits The Fan

10 months ago
How much cam Miller really do when his wingers are Lafriener...

In forum Where Smit Hits The Fan

10 months ago
Well they did ship out K-Poke  

In forum Where Smit Hits The Fan

10 months ago
Parsnips with a good shift  

In forum Where Smit Hits The Fan

10 months ago
MIKA...Finally

In forum Where Smit Hits The Fan

10 months ago
Tuned in 5 minutes late...Already 0-2

In forum Where Smit Hits The Fan

10 months ago
I wish Zib went with Kreider

In forum Where Smit Hits The Fan

10 months ago
Page 5 / 106