|
@@ -11,11 +11,11 @@ namespace App\ApiClient\DTOs;
|
|
|
final class DashboardStatsDto
|
|
final class DashboardStatsDto
|
|
|
{
|
|
{
|
|
|
/**
|
|
/**
|
|
|
- * @param list<array<string, mixed>> $reportsByHour entries shaped {hour, count}
|
|
|
|
|
- * @param list<array<string, mixed>> $topReporters entries shaped {name, count}
|
|
|
|
|
- * @param list<array<string, mixed>> $topCategories entries shaped {slug, count}
|
|
|
|
|
- * @param list<array<string, mixed>> $bansByDay entries shaped {day, count} — last 7 calendar days, zero-filled
|
|
|
|
|
- * @param list<array<string, mixed>> $jobsStatus entries shaped {name, last_finished_at, status, overdue}
|
|
|
|
|
|
|
+ * @param list<array<string, mixed>> $reportsByHour entries shaped {hour, count}
|
|
|
|
|
+ * @param list<array<string, mixed>> $topReporters entries shaped {name, count}
|
|
|
|
|
+ * @param list<array<string, mixed>> $topCategories entries shaped {slug, count}
|
|
|
|
|
+ * @param array{days: list<string>, series: list<array{category: string, counts: list<int>}>} $blockedByDay
|
|
|
|
|
+ * @param list<array<string, mixed>> $jobsStatus entries shaped {name, last_finished_at, status, overdue}
|
|
|
*/
|
|
*/
|
|
|
public function __construct(
|
|
public function __construct(
|
|
|
public readonly int $activeBlocks,
|
|
public readonly int $activeBlocks,
|
|
@@ -25,7 +25,7 @@ final class DashboardStatsDto
|
|
|
public readonly array $reportsByHour,
|
|
public readonly array $reportsByHour,
|
|
|
public readonly array $topReporters,
|
|
public readonly array $topReporters,
|
|
|
public readonly array $topCategories,
|
|
public readonly array $topCategories,
|
|
|
- public readonly array $bansByDay,
|
|
|
|
|
|
|
+ public readonly array $blockedByDay,
|
|
|
public readonly array $jobsStatus,
|
|
public readonly array $jobsStatus,
|
|
|
public readonly string $referencePolicy,
|
|
public readonly string $referencePolicy,
|
|
|
) {
|
|
) {
|
|
@@ -44,12 +44,44 @@ final class DashboardStatsDto
|
|
|
reportsByHour: self::extractList($payload, 'reports_24h_by_hour'),
|
|
reportsByHour: self::extractList($payload, 'reports_24h_by_hour'),
|
|
|
topReporters: self::extractList($payload, 'top_reporters_24h'),
|
|
topReporters: self::extractList($payload, 'top_reporters_24h'),
|
|
|
topCategories: self::extractList($payload, 'top_categories_24h'),
|
|
topCategories: self::extractList($payload, 'top_categories_24h'),
|
|
|
- bansByDay: self::extractList($payload, 'bans_by_day_7d'),
|
|
|
|
|
|
|
+ blockedByDay: self::extractBlocked($payload),
|
|
|
jobsStatus: self::extractList($payload, 'jobs_status'),
|
|
jobsStatus: self::extractList($payload, 'jobs_status'),
|
|
|
referencePolicy: (string) ($payload['reference_policy'] ?? 'moderate'),
|
|
referencePolicy: (string) ($payload['reference_policy'] ?? 'moderate'),
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param array<string, mixed> $payload
|
|
|
|
|
+ * @return array{days: list<string>, series: list<array{category: string, counts: list<int>}>}
|
|
|
|
|
+ */
|
|
|
|
|
+ private static function extractBlocked(array $payload): array
|
|
|
|
|
+ {
|
|
|
|
|
+ $raw = $payload['blocked_ips_by_day_7d'] ?? null;
|
|
|
|
|
+ if (!is_array($raw)) {
|
|
|
|
|
+ return ['days' => [], 'series' => []];
|
|
|
|
|
+ }
|
|
|
|
|
+ $days = [];
|
|
|
|
|
+ foreach ((array) ($raw['days'] ?? []) as $d) {
|
|
|
|
|
+ $days[] = (string) $d;
|
|
|
|
|
+ }
|
|
|
|
|
+ $series = [];
|
|
|
|
|
+ foreach ((array) ($raw['series'] ?? []) as $row) {
|
|
|
|
|
+ if (!is_array($row)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ $counts = [];
|
|
|
|
|
+ foreach ((array) ($row['counts'] ?? []) as $c) {
|
|
|
|
|
+ $counts[] = (int) $c;
|
|
|
|
|
+ }
|
|
|
|
|
+ $series[] = [
|
|
|
|
|
+ 'category' => (string) ($row['category'] ?? ''),
|
|
|
|
|
+ 'counts' => $counts,
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return ['days' => $days, 'series' => $series];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @param array<string, mixed> $payload
|
|
* @param array<string, mixed> $payload
|
|
|
* @return list<array<string, mixed>>
|
|
* @return list<array<string, mixed>>
|