// Генерация отчета по проблемным листингам add_action('wp_ajax_gpt_automation_generate_failed_report', 'gpt_automation_ajax_generate_failed_report'); function gpt_automation_ajax_generate_failed_report() { check_ajax_referer('gpt_automation_nonce', 'nonce'); if (!current_user_can('manage_options')) { wp_send_json_success(array('file_path' => $temp_file)); } // Добавление проблемных листингов в retry queue add_action('wp_ajax_gpt_automation_add_failed_to_retry', 'gpt_automation_ajax_add_failed_to_retry'); function gpt_automation_ajax_add_failed_to_retry() { check_ajax_referer('gpt_automation_nonce', 'nonce'); if (!current_user_can('manage_options')) { wp_send_json_error('Insufficient permissions'); } // Получаем проблемные листинги (та же логика) $failed_slugs = array(); // Листинги без GPT описания $missing_gpt_args = array( 'post_type' => 'listings', 'post_status' => 'publish', 'posts_per_page' => -1, 'fields' => 'ids', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'full_gpt', 'compare' => 'NOT EXISTS' ), array( 'key' => 'full_gpt', 'value' => '', 'compare' => '=' ), array( 'key' => 'full_gpt', 'value' => 'No long description available.', 'compare' => '=' ) ) ); $missing_gpt_query = new WP_Query($missing_gpt_args); foreach ($missing_gpt_query->posts as $post_id) { $post = get_post($post_id); $failed_slugs[] = $post->post_name; } // Листинги без видео $missing_video_args = array( 'post_type' => 'listings', 'post_status' => 'publish', 'posts_per_page' => -1, 'fields' => 'ids', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'video_url', 'compare' => 'NOT EXISTS' ), array( 'key' => 'video_url', 'value' => '', 'compare' => '=' ) ) ); $missing_video_query = new WP_Query($missing_video_args); foreach ($missing_video_query->posts as $post_id) { $post = get_post($post_id); $failed_slugs[] = $post->post_name; } // Убираем дубликаты $failed_slugs = array_unique($failed_slugs); if (empty($failed_slugs)) { wp_send_json_success('No failed listings found'); } // Добавляем в retry queue $retry_queue = get_option('gpt_automation_retry_queue', array()); $retry_queue = array_merge($retry_queue, $failed_slugs); $retry_queue = array_unique($retry_queue); update_option('gpt_automation_retry_queue', $retry_queue); gpt_automation_write_log("Added " . count($failed_slugs) . " failed listings to retry queue"); wp_send_json_success(count($failed_slugs) . " failed listings added to retry queue"); }_error('Insufficient permissions'); } // Поиск листингов с проблемами $failed_listings = array(); // Листинги без GPT описания $missing_gpt_args = array( 'post_type' => 'listings', 'post_status' => 'publish', 'posts_per_page' => -1, 'fields' => 'ids', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'full_gpt', 'compare' => 'NOT EXISTS' ), array( 'key' => 'full_gpt', 'value' => '', 'compare' => '=' ), array( 'key' => 'full_gpt', 'value' => 'No long description available.', 'compare' => '=' ) ) ); $missing_gpt_query = new WP_Query($missing_gpt_args); foreach ($missing_gpt_query->posts as $post_id) { $post = get_post($post_id); $failed_listings[$post->post_name] = array( 'slug' => $post->post_name, 'title' => get_field('title', $post_id) ?: $post->post_title, 'missing_gpt' => true, 'missing_video' => false ); } // Листинги без видео $missing_video_args = array( 'post_type' => 'listings', 'post_status' => 'publish', 'posts_per_page' => -1, 'fields' => 'ids', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'video_url', 'compare' => 'NOT EXISTS' ), array( 'key' => 'video_url', 'value' => '', 'compare' => '=' ) ) ); $missing_video_query = new WP_Query($missing_video_args); foreach ($missing_video_query->posts as $post_id) { $post = get_post($post_id); $slug = $post->post_name; if (isset($failed_listings[$slug])) { $failed_listings[$slug]['missing_video'] = true; } else { $failed_listings[$slug] = array( 'slug' => $slug, 'title' => get_field('title', $post_id) ?: $post->post_title, 'missing_gpt' => false, 'missing_video' => true ); } } // Формируем HTML отчет $html = '
'; $html .= '

Failed Listings Summary

'; $html .= '

Total failed listings: ' . count($failed_listings) . '

'; if (empty($failed_listings)) { $html .= '

🎉 All listings have complete data!

'; } else { $missing_gpt_count = 0; $missing_video_count = 0; $missing_both_count = 0; foreach ($failed_listings as $listing) { if ($listing['missing_gpt'] && $listing['missing_video']) { $missing_both_count++; } elseif ($listing['missing_gpt']) { $missing_gpt_count++; } elseif ($listing['missing_video']) { $missing_video_count++; } } $html .= ''; $html .= '

Detailed List:

'; $html .= '
'; foreach ($failed_listings as $listing) { $status_color = ''; $status_text = ''; if ($listing['missing_gpt'] && $listing['missing_video']) { $status_color = 'color: red;'; $status_text = 'Missing GPT + Video'; } elseif ($listing['missing_gpt']) { $status_color = 'color: orange;'; $status_text = 'Missing GPT'; } elseif ($listing['missing_video']) { $status_color = 'color: blue;'; $status_text = 'Missing Video'; } $html .= '
'; $html .= '' . esc_html($listing['slug']) . ' - ' . esc_html($listing['title']); $html .= ' [' . $status_text . ']'; $html .= '
'; } $html .= '
'; } $html .= '
'; wp_send_json_success(array( 'html' => $html, 'count' => count($failed_listings), 'slugs' => array_keys($failed_listings) )); } // Скачивание списка проблемных слагов add_action('wp_ajax_gpt_automation_download_failed_slugs', 'gpt_automation_ajax_download_failed_slugs'); function gpt_automation_ajax_download_failed_slugs() { check_ajax_referer('gpt_automation_nonce', 'nonce'); if (!current_user_can('manage_options')) { wp_send_json_error('Insufficient permissions'); } // Получаем проблемные листинги (копируем логику из предыдущей функции) $failed_listings = array(); // Листинги без GPT описания $missing_gpt_args = array( 'post_type' => 'listings', 'post_status' => 'publish', 'posts_per_page' => -1, 'fields' => 'ids', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'full_gpt', 'compare' => 'NOT EXISTS' ), array( 'key' => 'full_gpt', 'value' => '', 'compare' => '=' ), array( 'key' => 'full_gpt', 'value' => 'No long description available.', 'compare' => '=' ) ) ); $missing_gpt_query = new WP_Query($missing_gpt_args); foreach ($missing_gpt_query->posts as $post_id) { $post = get_post($post_id); $failed_listings[$post->post_name] = array( 'slug' => $post->post_name, 'title' => get_field('title', $post_id) ?: $post->post_title, 'missing_gpt' => true, 'missing_video' => false ); } // Листинги без видео $missing_video_args = array( 'post_type' => 'listings', 'post_status' => 'publish', 'posts_per_page' => -1, 'fields' => 'ids', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'video_url', 'compare' => 'NOT EXISTS' ), array( 'key' => 'video_url', 'value' => '', 'compare' => '=' ) ) ); $missing_video_query = new WP_Query($missing_video_args); foreach ($missing_video_query->posts as $post_id) { $post = get_post($post_id); $slug = $post->post_name; if (isset($failed_listings[$slug])) { $failed_listings[$slug]['missing_video'] = true; } else { $failed_listings[$slug] = array( 'slug' => $slug, 'title' => get_field('title', $post_id) ?: $post->post_title, 'missing_gpt' => false, 'missing_video' => true ); } } // Создаем временный файл $temp_file = get_template_directory() . '/gpt-logs/failed_listings_' . date('Y-m-d-H-i-s') . '.txt'; $content = "Failed Listings Report - " . date('Y-m-d H:i:s') . "\n"; $content .= "Total failed listings: " . count($failed_listings) . "\n\n"; foreach ($failed_listings as $listing) { $status = ''; if ($listing['missing_gpt'] && $listing['missing_video']) { $status = '[Missing GPT + Video]'; } elseif ($listing['missing_gpt']) { $status = '[Missing GPT]'; } elseif ($listing['missing_video']) { $status = '[Missing Video]'; } $content .= $listing['slug'] . " - " . $listing['title'] . " " . $status . "\n"; } file_put_contents($temp_file, $content); wp_send_json_success(array('file_path' => $temp_file)); Page not found – Dyora
Add Listing

404

We're sorry, but the Page you were looking for, couldn't be found.

Or

Back to Home Page

Location for : Listing Title