/** * 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'] ); } } } } x10003q – Activity – OutsideTheGarden Boards – Page 60
JUNE
«
Thu
17
Fri
18
Sat
19
Sun
20
Mon
21
Tue
22
Wed
23
»
x10003q
x10003q
Group: Registered
Joined: 2023-09-04
Legend
Follow
4:04 left - Rangers still cant clear the puck. So painful.

In forum Where Smit Hits The Fan

9 months ago
Rangers trying to give up another goal

In forum Where Smit Hits The Fan

9 months ago
Jarvis from Gostisbeeeeeer over Igor's right shoulder 3-2, 9...

In forum Where Smit Hits The Fan

9 months ago
Rangers playing hot potato with the puck in their own end. T...

In forum Where Smit Hits The Fan

9 months ago
K Miller gets iron

In forum Where Smit Hits The Fan

9 months ago
inside the first minute

In forum Where Smit Hits The Fan

9 months ago
Panarin feeds Trocheck 3-1

In forum Where Smit Hits The Fan

9 months ago
rangers shots 13-24, end of 2 2-1 Strong PK after ...

In forum Where Smit Hits The Fan

9 months ago
5.2 left d FO

In forum Where Smit Hits The Fan

9 months ago
yes - hope all is well  

In forum Where Smit Hits The Fan

9 months ago
trocheck wins the draw - miller back to fox to panarin 1 tim...

In forum Where Smit Hits The Fan

9 months ago
Gav got hit by a shot in the left leg and went down. just so...

In forum Where Smit Hits The Fan

9 months ago
3 cane pp in a row

In forum Where Smit Hits The Fan

9 months ago
Boyle things it is a bullshit call - and it was

In forum Where Smit Hits The Fan

9 months ago
Walker loses an edge on the way into the boards with berard ...

In forum Where Smit Hits The Fan

9 months ago
Page 60 / 417