aboutsummaryrefslogtreecommitdiff
path: root/api/debug/stats.php
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-07-29 20:46:12 +0200
committerAgando <roduccomm@gmail.com>2026-07-29 20:46:12 +0200
commit0003ad95fa091353827198d0a45cd63a3784479f (patch)
tree4ea79302c13f34b2f1b84a56ed33cc149cd99a21 /api/debug/stats.php
parentcf7461ffeb4f53f3f50c9c692a2e4fdcecf17e82 (diff)
auto: 2026-07-29_20:50 changes — gunes sponsorluk page, bunq payment modal, AI platforms, news W30
Diffstat (limited to 'api/debug/stats.php')
-rw-r--r--api/debug/stats.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/api/debug/stats.php b/api/debug/stats.php
new file mode 100644
index 0000000..dd0b0db
--- /dev/null
+++ b/api/debug/stats.php
@@ -0,0 +1,55 @@
+<?php
+require_once __DIR__ . '/config.php';
+
+$errors = load_json(ERRORS_FILE);
+$sessions = load_json(SESSIONS_FILE);
+
+$total = count($errors);
+$byType = [];
+$bySeverity = [];
+$byCategory = [];
+$byModule = [];
+$byDay = [];
+$topErrors = [];
+
+foreach ($errors as $e) {
+ $t = $e['type'] ?? 'unknown';
+ $byType[$t] = ($byType[$t] ?? 0) + ($e['count'] ?? 1);
+
+ $s = $e['severity'] ?? 'error';
+ $bySeverity[$s] = ($bySeverity[$s] ?? 0) + ($e['count'] ?? 1);
+
+ $c = $e['category'] ?? 'runtime';
+ $byCategory[$c] = ($byCategory[$c] ?? 0) + ($e['count'] ?? 1);
+
+ $m = $e['module'] ?? 'unknown';
+ $byModule[$m] = ($byModule[$m] ?? 0) + ($e['count'] ?? 1);
+
+ $day = substr($e['ingested_at'] ?? $e['last_seen'], 0, 10);
+ $byDay[$day] = ($byDay[$day] ?? 0) + ($e['count'] ?? 1);
+
+ $hash = $e['hash'] ?? '';
+ if ($hash) {
+ if (!isset($topErrors[$hash])) {
+ $topErrors[$hash] = ['hash' => $hash, 'message' => $e['message'] ?? '', 'count' => 0, 'type' => $t];
+ }
+ $topErrors[$hash]['count'] += $e['count'] ?? 1;
+ }
+}
+
+usort($topErrors, fn($a, $b) => $b['count'] - $a['count']);
+$topErrors = array_slice($topErrors, 0, 20);
+ksort($byDay);
+
+json_response([
+ 'success' => true,
+ 'total_errors' => $total,
+ 'total_sessions' => count($sessions),
+ 'by_type' => $byType,
+ 'by_severity' => $bySeverity,
+ 'by_category' => $byCategory,
+ 'by_module' => $byModule,
+ 'by_day' => $byDay,
+ 'top_errors' => $topErrors,
+ 'generated_at' => date('c'),
+]);