-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
136 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#standardSQL | ||
# Get summary of all lighthouse scores for a category for PWA pages | ||
# Note scores, weightings, groups and descriptions may be off in mixed months when new versions of Lighthouse roles out | ||
|
||
CREATE TEMPORARY FUNCTION getAudits(report STRING, category STRING) | ||
RETURNS ARRAY<STRUCT<id STRING, weight INT64, audit_group STRING, title STRING, description STRING, score INT64>> LANGUAGE js AS ''' | ||
var $ = JSON.parse(report); | ||
var auditrefs = $.categories[category].auditRefs; | ||
var audits = $.audits; | ||
$ = null; | ||
var results = []; | ||
for (auditref of auditrefs) { | ||
results.push({ | ||
id: auditref.id, | ||
weight: auditref.weight, | ||
audit_group: auditref.group, | ||
description: audits[auditref.id].description, | ||
score: audits[auditref.id].score | ||
}); | ||
} | ||
return results; | ||
'''; | ||
|
||
SELECT | ||
audits.id AS id, | ||
COUNTIF(audits.score > 0) AS num_pages, | ||
COUNT(0) AS total, | ||
COUNTIF(audits.score IS NOT NULL) AS total_applicable, | ||
SAFE_DIVIDE(COUNTIF(audits.score > 0), COUNTIF(audits.score IS NOT NULL)) AS pct, | ||
APPROX_QUANTILES(audits.weight, 100)[OFFSET(50)] AS median_weight, | ||
MAX(audits.audit_group) AS audit_group, | ||
MAX(audits.description) AS description | ||
FROM | ||
`httparchive.lighthouse.2020_08_01_mobile` l, | ||
`httparchive.almanac.service_workers` sw, | ||
UNNEST(getAudits(report, "pwa")) AS audits | ||
WHERE | ||
date = '2020-08-01' AND | ||
client = 'mobile' AND | ||
page = l.url AND | ||
LENGTH(report) < 20000000 # necessary to avoid out of memory issues. Excludes 16 very large results | ||
GROUP BY | ||
audits.id | ||
ORDER BY | ||
median_weight DESC, | ||
id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.