Skip to content

Commit df280a1

Browse files
committed
requests processed in 4 steps
1 parent 85fd06d commit df280a1

File tree

2 files changed

+23
-38
lines changed

2 files changed

+23
-38
lines changed

definitions/output/crawl/requests.js

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,42 +38,28 @@ publish('requests', {
3838
},
3939
tags: ['crawl_complete']
4040
}).preOps(ctx => `
41-
CREATE TEMP FUNCTION pruneHeaders(
42-
jsonObject JSON
43-
) RETURNS JSON
44-
LANGUAGE js AS '''
45-
try {
46-
for (const [key, value] of Object.entries(jsonObject)) {
47-
if(key.startsWith('req_') || key.startsWith('resp_')) {
48-
delete jsonObject[key]
49-
}
50-
}
51-
return jsonObject
52-
} catch (e) {
53-
return jsonObject
54-
}
55-
''';
41+
FOR client_value IN (SELECT * FROM UNNEST(['desktop', 'mobile']) AS client) DO
42+
FOR is_root_page_value IN (SELECT * FROM UNNEST([TRUE, FALSE]) AS is_root_page) DO
5643
57-
DELETE FROM ${ctx.self()}
58-
WHERE date = '${constants.currentMonth}' AND
59-
client = 'desktop';
60-
`).query(ctx => `
61-
SELECT
62-
*
63-
FROM ${ctx.ref('crawl_staging', 'requests')}
64-
WHERE date = '${constants.currentMonth}' AND
65-
client = 'desktop'
66-
${constants.devRankFilter}
67-
`).postOps(ctx => `
68-
DELETE FROM ${ctx.self()}
69-
WHERE date = '${constants.currentMonth}' AND
70-
client = 'mobile';
44+
-- Delete old entries
45+
DELETE FROM ${ctx.self()}
46+
WHERE date = '${constants.currentMonth}'
47+
AND client = client_value.client
48+
AND is_root_page = is_root_page_value.is_root_page;
7149
72-
INSERT INTO ${ctx.self()}
73-
SELECT
74-
*
50+
-- Insert new entries
51+
INSERT INTO ${ctx.self()}
52+
SELECT *
53+
FROM ${ctx.ref('crawl_staging', 'requests')}
54+
WHERE date = '${constants.currentMonth}' AND
55+
client = client_value.client AND
56+
is_root_page = is_root_page_value.is_root_page ${constants.devRankFilter};
57+
58+
END FOR;
59+
END FOR;
60+
`).query(ctx => `
61+
SELECT *
7562
FROM ${ctx.ref('crawl_staging', 'requests')}
76-
WHERE date = '${constants.currentMonth}' AND
77-
client = 'mobile'
78-
${constants.devRankFilter}
63+
WHERE date IS NULL ${constants.devRankFilter}
64+
LIMIT 0
7965
`)

definitions/output/reports/cwv_tech_categories.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ WITH pages AS (
1515
date = '${pastMonth}' AND
1616
client = 'mobile'
1717
${constants.devRankFilter}
18-
),categories AS (
18+
), categories AS (
1919
SELECT
2020
category,
2121
COUNT(DISTINCT root_page) AS origins
2222
FROM pages,
2323
UNNEST(technologies) AS t,
2424
UNNEST(t.categories) AS category
2525
GROUP BY category
26-
),
27-
technologies AS (
26+
), technologies AS (
2827
SELECT
2928
category,
3029
technology,

0 commit comments

Comments
 (0)