diff --git a/ai-summary-query.php b/ai-summary-query.php index 3b853e1..8b73879 100644 --- a/ai-summary-query.php +++ b/ai-summary-query.php @@ -605,6 +605,365 @@ html.darkmode .ai-verify-subtitle { color: #aaa; } +get_results(" + SELECT pm.post_id, pm.meta_value as code, pm2.meta_value as time + FROM {$wpdb->postmeta} pm + LEFT JOIN {$wpdb->postmeta} pm2 ON pm.post_id = pm2.post_id AND pm2.meta_key = '_argon_ai_summary_time' + WHERE pm.meta_key = '_argon_ai_summary_code' + ORDER BY pm2.meta_value DESC + LIMIT 50 + "); + + // 获取所有垃圾评论检测记录 + $spam_detections = $wpdb->get_results(" + SELECT cm.comment_id, cm.meta_value as code, cm2.meta_value as time + FROM {$wpdb->commentmeta} cm + LEFT JOIN {$wpdb->commentmeta} cm2 ON cm.comment_id = cm2.comment_id AND cm2.meta_key = '_argon_spam_detection_time' + WHERE cm.meta_key = '_argon_spam_detection_code' + ORDER BY cm2.meta_value DESC + LIMIT 50 + "); + + // 合并并按时间排序 + $all_records = []; + + foreach ($summaries as $summary) { + $post = get_post($summary->post_id); + if ($post) { + $all_records[] = [ + 'type' => 'summary', + 'code' => $summary->code, + 'time' => $summary->time ? intval($summary->time) : 0, + 'title' => get_the_title($summary->post_id), + 'url' => get_permalink($summary->post_id), + 'id' => $summary->post_id, + 'data' => [ + 'post_id' => $summary->post_id, + 'post_title' => get_the_title($summary->post_id), + 'post_url' => get_permalink($summary->post_id), + 'summary' => get_post_meta($summary->post_id, '_argon_ai_summary', true), + 'model' => get_post_meta($summary->post_id, '_argon_ai_summary_model', true), + 'provider' => get_post_meta($summary->post_id, '_argon_ai_summary_provider', true), + 'generated_time' => $summary->time + ] + ]; + } + } + + foreach ($spam_detections as $detection) { + $comment = get_comment($detection->comment_id); + if ($comment) { + $detection_result = get_comment_meta($detection->comment_id, '_argon_spam_detection_result', true); + $all_records[] = [ + 'type' => 'spam_detection', + 'code' => $detection->code, + 'time' => $detection->time ? intval($detection->time) : 0, + 'title' => sprintf(__('评论 #%d - %s', 'argon'), $detection->comment_id, $comment->comment_author), + 'url' => get_comment_link($comment), + 'id' => $detection->comment_id, + 'data' => [ + 'comment_id' => $detection->comment_id, + 'comment_author' => $comment->comment_author, + 'comment_content' => $comment->comment_content, + 'comment_date' => $comment->comment_date, + 'post_title' => get_the_title($comment->comment_post_ID), + 'post_url' => get_permalink($comment->comment_post_ID), + 'is_spam' => isset($detection_result['is_spam']) ? $detection_result['is_spam'] : false, + 'reason' => isset($detection_result['reason']) ? $detection_result['reason'] : '', + 'action' => isset($detection_result['action']) ? $detection_result['action'] : '', + 'detection_time' => $detection->time + ] + ]; + } + } + + // 按时间倒序排序 + usort($all_records, function($a, $b) { + return $b['time'] - $a['time']; + }); + + // 只保留前50条 + $all_records = array_slice($all_records, 0, 50); + + if (!empty($all_records)): +?> + +
+

+ + + () + +

+ +
+ + +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
+ + +
+
+
+

+ +
+
+ +
+
+
+ + + + + + +