-
Notifications
You must be signed in to change notification settings - Fork 0
Completing reports migration #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
8854387
fix discrepancies
max-ostapenko bf90fd8
lenses
max-ostapenko 65062af
Merge branch 'main' into standard_reports
max-ostapenko 5637e83
sql updated
max-ostapenko 55adcf4
lenses path
max-ostapenko 385e426
spelling fix
max-ostapenko 1b3678c
all metrics in the same table
max-ostapenko e2ce0dd
aggregated tables
max-ostapenko 6bb7ce4
storage sync script
max-ostapenko 28cebce
Merge branch 'main' into standard_reports
max-ostapenko 00a4b4e
Merge branch 'main' into standard_reports
max-ostapenko 044c9c7
conditional path
max-ostapenko 633895c
Merge branch 'main' into standard_reports
max-ostapenko c26f79e
Merge remote-tracking branch 'origin/main' into standard_reports
max-ostapenko 727c3c6
common lenses
max-ostapenko a816f79
Merge branch 'main' into standard_reports
max-ostapenko 9b2e192
Merge branch 'main' into standard_reports
max-ostapenko 8e9dc27
lint
max-ostapenko 53dab5c
Merge branch 'main' into standard_reports
max-ostapenko 53c133e
Merge branch 'main' into standard_reports
max-ostapenko 390269b
update
max-ostapenko 5457752
bytesTotal tested
max-ostapenko 9a360df
beautified
max-ostapenko 50d9522
formatting
max-ostapenko 8a294e8
sync storage export
max-ostapenko ab584a6
docs
max-ostapenko 40ed9f5
rename
max-ostapenko 812838a
Merge branch 'main' into standard_reports
max-ostapenko e2663bd
cleanup
max-ostapenko 90dff99
VALIDATE_EDITORCONFIG
max-ostapenko 277e1d3
lint
max-ostapenko cbf8ad9
cleanup
max-ostapenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -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) | ||
) | ||
}) | ||
} |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.