Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8854387
fix discrepancies
max-ostapenko Dec 28, 2024
bf90fd8
lenses
max-ostapenko Jan 7, 2025
65062af
Merge branch 'main' into standard_reports
max-ostapenko Jan 7, 2025
5637e83
sql updated
max-ostapenko Jan 7, 2025
55adcf4
lenses path
max-ostapenko Jan 7, 2025
385e426
spelling fix
max-ostapenko Jan 7, 2025
1b3678c
all metrics in the same table
max-ostapenko Jan 12, 2025
e2ce0dd
aggregated tables
max-ostapenko Jan 14, 2025
6bb7ce4
storage sync script
max-ostapenko Jan 14, 2025
28cebce
Merge branch 'main' into standard_reports
max-ostapenko Jan 21, 2025
00a4b4e
Merge branch 'main' into standard_reports
max-ostapenko Jan 26, 2025
044c9c7
conditional path
max-ostapenko Jan 26, 2025
633895c
Merge branch 'main' into standard_reports
max-ostapenko Feb 16, 2025
c26f79e
Merge remote-tracking branch 'origin/main' into standard_reports
max-ostapenko Jun 16, 2025
727c3c6
common lenses
max-ostapenko Jun 16, 2025
a816f79
Merge branch 'main' into standard_reports
max-ostapenko Jun 18, 2025
9b2e192
Merge branch 'main' into standard_reports
max-ostapenko Jun 18, 2025
8e9dc27
lint
max-ostapenko Jun 18, 2025
53dab5c
Merge branch 'main' into standard_reports
max-ostapenko Jul 6, 2025
53c133e
Merge branch 'main' into standard_reports
max-ostapenko Jul 30, 2025
390269b
update
max-ostapenko Jul 30, 2025
5457752
bytesTotal tested
max-ostapenko Jul 31, 2025
9a360df
beautified
max-ostapenko Jul 31, 2025
50d9522
formatting
max-ostapenko Jul 31, 2025
8a294e8
sync storage export
max-ostapenko Jul 31, 2025
ab584a6
docs
max-ostapenko Jul 31, 2025
40ed9f5
rename
max-ostapenko Jul 31, 2025
812838a
Merge branch 'main' into standard_reports
max-ostapenko Jul 31, 2025
e2663bd
cleanup
max-ostapenko Jul 31, 2025
90dff99
VALIDATE_EDITORCONFIG
max-ostapenko Jul 31, 2025
277e1d3
lint
max-ostapenko Jul 31, 2025
cbf8ad9
cleanup
max-ostapenko Jul 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 57 additions & 30 deletions definitions/output/reports/reports_dynamic.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,74 @@
const configs = new reports.HTTPArchiveReports()
const metrics = configs.listMetrics()

// Adjust start and end dates to update reports retrospectively
const startDate = '2024-12-01' // constants.currentMonth;
const endDate = '2024-12-01' // constants.currentMonth;

const lenses = {
all: '',
top1k: 'AND rank <= 1000',
top10k: 'AND rank <= 10000',
top100k: 'AND rank <= 100000',
top1m: 'AND rank <= 1000000',
drupal: 'AND \'Drupal\' IN UNNEST(technologies.technology)',
magento: 'AND \'Magento\' IN UNNEST(technologies.technology)',
wordpress: 'AND \'WordPress\' IN UNNEST(technologies.technology)'
}

const iterations = []
// dates
for (
let month = constants.currentMonth; month >= constants.currentMonth; month = constants.fnPastMonth(month)) {
iterations.push({
date: month,
devRankFilter: constants.devRankFilter
let date = endDate;
date >= startDate;
date = constants.fnPastMonth(date)
) {
// metrics
metrics.forEach(metric => {
// timeseries and histograms
metric.SQL.forEach(sql => {
// lenses
for (const [key, value] of Object.entries(lenses)) {
iterations.push({
date,
metric,
sql,
lense: { key, value },
devRankFilter: constants.devRankFilter
})
}
})
})
}

if (iterations.length === 1) {
const params = iterations[0]
metrics.forEach(metric => {
metric.SQL.forEach(sql => {
publish(metric.id + '_' + sql.type, {
type: 'incremental',
protected: true,
bigquery: sql.type === 'histogram' ? { partitionBy: 'date', clusterBy: ['client'] } : {},
schema: 'reports',
tags: ['crawl_complete']
}).preOps(ctx => `
if (startDate === endDate) {
iterations.forEach((params, i) => {
publish(params.metric.id + '_' + params.sql.type + '_' + params.lense.key, {
type: 'incremental',
protected: true,
bigquery: params.sql.type === 'histogram' ? { partitionBy: 'date', clusterBy: ['client'] } : {},
schema: 'reports',
tags: ['crawl_complete', 'reports']
}).preOps(ctx => `
--DELETE FROM ${ctx.self()}
--WHERE date = '${params.date}';
`).query(ctx => `
/* {"dataform_trigger": "report_complete", "date": "${params.date}", "name": "${metric.id}", "type": "${sql.type}"} */` +
sql.query(ctx, params))
})
`).query(ctx => `
/* {"dataform_trigger": "report_complete", "date": "${params.date}", "name": "${params.metric.id}", "type": "${params.sql.type}", "lense": "${params.lense.key}"} */` +
params.sql.query(ctx, params)
)
})
} else {
iterations.forEach((params, i) => {
metrics.forEach(metric => {
metric.SQL.forEach(sql => {
operate(metric.id + '_' + sql.type + '_' + params.date, {
tags: ['crawl_complete']
}).queries(ctx => `
DELETE FROM reports.${metric.id}_${sql.type}
operate(
params.metric.id + '_' + params.sql.type + '_' + params.lense.key + '_' + params.date)
.tags(['crawl_complete', 'reports'])
.queries(ctx => `
DELETE FROM reports.${params.metric.id}_${params.sql.type}
WHERE date = '${params.date}';
/* {"dataform_trigger": "report_complete", "date": "${params.date}", "name": "${metric.id}", "type": "${sql.type}"} */
INSERT INTO reports.${metric.id}_${sql.type}` +
sql.query(ctx, params))
})
})
/* {"dataform_trigger": "report_complete", "date": "${params.date}", "name": "${params.metric.id}", "type": "${params.sql.type}", "lense": "${params.lense.key}"} */
INSERT INTO reports.${params.metric.id}_${params.sql.type}` +
params.sql.query(ctx, params)
)
})
}
10 changes: 8 additions & 2 deletions includes/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ FROM (
COUNT(0) AS volume
FROM ${ctx.ref('crawl', 'pages')}
WHERE
date = '${params.date}' ${params.devRankFilter}
date = '${params.date}' ${params.devRankFilter} AND
is_root_page AND
INT64(summary.bytesTotal) > 0
GROUP BY
date,
client,
bin
HAVING bin IS NOT NULL
)
)
ORDER BY
date,
bin,
client
`)
},
{
Expand All @@ -52,6 +57,7 @@ FROM (
FROM ${ctx.ref('crawl', 'pages')}
WHERE
date = '${params.date}' ${params.devRankFilter} AND
is_root_page AND
INT64(summary.bytesTotal) > 0
)
GROUP BY
Expand Down
Loading