
// TEMP DEBUG - remove after use
add_action('wp_ajax_hc_debug_info', function() {
    global $wpdb;
    $tables = $wpdb->get_results("SHOW TABLES LIKE '%pick%'", ARRAY_N);
    $tableNames = array_map(function($t){ return $t[0]; }, $tables);
    
    // Get picks table name
    $picksTable = '';
    foreach($tableNames as $t) {
        if(strpos($t,'result') === false) $picksTable = $t;
    }
    
    // Sample ungraded pick
    $pick = $wpdb->get_row("SELECT * FROM {$picksTable} WHERE status NOT IN ('Win','Lost','Tie') LIMIT 1");
    
    // Get plugin file content (lines 30+)
    $file = file_get_contents(WP_PLUGIN_DIR . '/handicapper-api/handicapper-api.php');
    $lines = explode("\n", $file);
    $rest = implode("\n", array_slice($lines, 30));
    
    // Also get get-pick-results.php lines 30+
    $file2 = file_get_contents(WP_PLUGIN_DIR . '/handicapper-api/get-pick-results.php');
    $lines2 = explode("\n", $file2);
    $rest2 = implode("\n", array_slice($lines2, 30));
    
    // Get a sample JSONOdds result to see field names
    $ch = curl_init();
    curl_setopt_array($ch, [CURLOPT_URL=>'https://api.jsonodds.com/api/results/nba?final=true&oddType=Game',CURLOPT_RETURNTRANSFER=>true,CURLOPT_TIMEOUT=>10,CURLOPT_HTTPHEADER=>['x-api-key: e5306273-a3ee-4fe9-b608-fbfa47d28aa1']]);
    $apiResp = curl_exec($ch);
    curl_close($ch);
    $apiData = json_decode($apiResp, true);
    $firstGame = $apiData ? $apiData[0] : [];
    
    update_option('hc_debug_dump', json_encode([
        'tables'=>$tableNames,'picks_table'=>$picksTable,'api_keys'=>array_keys($firstGame),'plugin_tail'=>substr($file,-800),'picks_tail'=>substr($file2,-800)
    ]));
    echo json_encode([
        'tables' => $tableNames,
        'picks_table' => $picksTable,
        'sample_pick' => $pick,
        'api_first_game_keys' => array_keys($firstGame),
        'api_first_game' => $firstGame,
        'plugin_lines_30plus' => $rest,
        'get_pick_lines_30plus' => $rest2,
    ]);
    wp_die();
});
// END TEMP DEBUG
