/** * 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 95
AUGUST
«
Sat
1
NHL Arbitration
Sun
2
Mon
3
Tue
4
Wed
5
Thu
6
Fri
7
»
Rangerjunkiekimmie
Rangerjunkiekimmie
Group: Registered
Joined: 2023-08-26
NHL All Star
2
Follow
No, it's the players who have no clue

In forum Where Smit Hits The Fan

3 years ago
Even Vegas' AHL'ers are better than ours

In forum Where Smit Hits The Fan

3 years ago
At least Panarin is keeping his assist streak going

In forum Where Smit Hits The Fan

3 years ago
Yikes

In forum Where Smit Hits The Fan

3 years ago
He hasn't looked good for over a month

In forum Where Smit Hits The Fan

3 years ago
Good kill

In forum Where Smit Hits The Fan

3 years ago
No Lindgrin

In forum Where Smit Hits The Fan

3 years ago
It looked like a Kreider hit

In forum Where Smit Hits The Fan

3 years ago
Wheeler with more goals than Zib in the last 10 games

In forum Where Smit Hits The Fan

3 years ago
Bonino would have blocked that shot

In forum Where Smit Hits The Fan

3 years ago
0-1 Of course

In forum Where Smit Hits The Fan

3 years ago
Schneider taking the body!!

In forum Where Smit Hits The Fan

3 years ago
And no Bonino blocking shots

In forum Where Smit Hits The Fan

3 years ago
I would take a chance on Morgan Frost... PLEASE NO to Haye...

In forum Where Smit Hits The Fan

3 years ago
And they are able to hold on Back in the win column

In forum Where Smit Hits The Fan

3 years ago
Page 95 / 106