Skip to content

Commit 2096899

Browse files
pages_per_client assert (#155)
* fix month * fix column order * pages_per_client assert
1 parent 08bca57 commit 2096899

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

definitions/output/crawl/pages.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ ORDER BY cnt_pages DESC
3232
HAVING cnt_pages > 200
3333
`)
3434

35+
assert('pages_per_client')
36+
.tags(['crawl_complete'])
37+
.query(ctx => `
38+
SELECT
39+
client,
40+
COUNT(DISTINCT page) AS cnt_pages
41+
FROM ${ctx.ref('crawl_staging', 'pages')}
42+
WHERE
43+
date = '${constants.currentMonth}'
44+
GROUP BY
45+
client
46+
HAVING cnt_pages < 20000000
47+
`)
48+
3549
publish('pages', {
3650
type: 'incremental',
3751
protected: true,

definitions/output/reports/reports_html_elements_popularity.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const pastMonth = constants.fnPastMonth(constants.currentMonth)
2-
31
publish('html_elements_popularity', {
42
schema: 'reports',
53
type: 'incremental',
@@ -18,7 +16,7 @@ try {
1816
''';
1917
2018
DELETE FROM ${ctx.self()}
21-
WHERE date = '${pastMonth}';
19+
WHERE date = '${constants.currentMonth}';
2220
`).query(ctx => `
2321
WITH pages_data AS (
2422
SELECT
@@ -29,7 +27,7 @@ WITH pages_data AS (
2927
custom_metrics.element_count
3028
FROM ${ctx.ref('crawl', 'pages')}
3129
WHERE
32-
date = '${pastMonth}' ${constants.devRankFilter}
30+
date = '${constants.currentMonth}' ${constants.devRankFilter}
3331
),
3432
3533
totals AS (
@@ -69,9 +67,9 @@ SELECT
6967
"destination": "cloud_storage",
7068
"config": {
7169
"bucket": "${constants.bucket}",
72-
"name": "${constants.storagePath}${pastMonth.replaceAll('-', '_')}/htmlElementPopularity.json"
70+
"name": "${constants.storagePath}${constants.currentMonth.replaceAll('-', '_')}/htmlElementPopularity.json"
7371
},
74-
"query": "SELECT * EXCEPT(date) FROM ${ctx.self()} WHERE date = '${pastMonth}'"
72+
"query": "SELECT * EXCEPT(date) FROM ${ctx.self()} WHERE date = '${constants.currentMonth}'"
7573
}'''
7674
);
7775
`)

0 commit comments

Comments
 (0)