Skip to content

Commit

Permalink
Copyedit 2020 PWA chapter (#1924)
Browse files Browse the repository at this point in the history
* Copyedit PWA chapter

* Capitalisation
  • Loading branch information
tunetheweb authored Jan 27, 2021
1 parent ad1cc10 commit 429cda3
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 89 deletions.
46 changes: 46 additions & 0 deletions sql/2020/14_PWA/lighthouse_pwa_audits_sw.sql
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
2 changes: 1 addition & 1 deletion src/config/2020.json
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@
"github": "gregorywolf"
},
"hemanth": {
"name": "hemanth.hm",
"name": "Hemanth HM",
"teams": [
"authors"
],
Expand Down
Loading

0 comments on commit 429cda3

Please sign in to comment.