Extract Lighthouse findings
pauljd/davidson-ci: Davidson CI / ai-review (push) Successful in 1m3s
pauljd/davidson-ci: Davidson CI / quality (push) Successful in 1m29s

This commit is contained in:
2026-09-12 20:13:44 +01:00
parent 74b8e9dd2f
commit b9630c69f8
2 changed files with 56 additions and 1 deletions
+52 -1
View File
@@ -55,6 +55,22 @@ $categoryIds = [
$scores = [];
$auditCategories = [];
foreach ($categoryIds as $categoryId) {
$auditRefs = $data['categories'][$categoryId]['auditRefs'] ?? [];
foreach ($auditRefs as $auditRef) {
$auditId = $auditRef['id'] ?? null;
if ($auditId === null) {
continue;
}
$auditCategories[$auditId][] = $categoryId;
}
}
foreach ($categoryIds as $categoryId) {
$rawScore = $data['categories'][$categoryId]['score'] ?? null;
@@ -72,10 +88,45 @@ foreach ($categoryIds as $categoryId) {
];
}
$findings = [];
$skipModes = [
'notApplicable',
'informative',
'manual',
'error',
];
foreach ($data['audits'] ?? [] as $auditId => $audit) {
$score = $audit['score'] ?? null;
$scoreDisplayMode = $audit['scoreDisplayMode'] ?? null;
if ($score === null) {
continue;
}
if (in_array($scoreDisplayMode, $skipModes, true)) {
continue;
}
if (!is_numeric($score) || $score >= 1) {
continue;
}
$findings[] = [
'id' => $auditId,
'categories' => $auditCategories[$auditId] ?? [],
'title' => $audit['title'] ?? $auditId,
'problem' => $audit['description'] ?? '',
'impact' => $audit['displayValue'] ?? null,
'score' => (int) round($score * 100),
];
}
$output = [
'schemaVersion' => 1,
'scores' => $scores,
'findings' => [],
'findings' => $findings,
];
$outputJson = json_encode(