Skip to content

Commit 9d20b27

Browse files
Migrating all crawl reports (#141)
* all crawl reports * feat: Add histogram and timeseries data synchronization scripts - Implemented histogram_storage_sync.js for downloading and uploading histogram data to BigQuery. - Created timeseries_storage_sync.js for processing timeseries data with similar functionality. - Added package.json to manage dependencies for Google Cloud Storage and BigQuery. * lint * Potential fix for pull request finding 'Unhandled error in stream pipeline' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> * Potential fix for pull request finding 'Unhandled error in stream pipeline' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
1 parent dd2c784 commit 9d20b27

5 files changed

Lines changed: 3309 additions & 40 deletions

File tree

definitions/output/reports/reports_dynamic.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const EXPORT_CONFIG = {
2424
bucket: constants.bucket,
2525
storagePath: constants.storagePath,
2626
dataset: 'reports',
27-
testSuffix: '.json'
27+
fileFormat: '.json'
2828
}
2929

3030
// Date range for report generation
@@ -54,7 +54,7 @@ function buildExportPath(reportConfig) {
5454
throw new Error(`Unknown SQL type: ${sql.type}`)
5555
}
5656

57-
return objectPath + EXPORT_CONFIG.testSuffix
57+
return objectPath + EXPORT_CONFIG.fileFormat
5858
}
5959

6060
/**
@@ -74,17 +74,19 @@ function buildExportQuery(reportConfig) {
7474
WHERE date = '${date}'
7575
AND metric = '${metric.id}'
7676
AND lens = '${lens.name}'
77-
ORDER BY bin ASC
77+
ORDER BY client, bin ASC
7878
`
7979
} else if (sql.type === 'timeseries') {
8080
query = `
8181
SELECT
82-
FORMAT_DATE('%Y_%m_%d', date) AS date,
82+
UNIX_DATE(date) * 1000 * 60 * 60 * 24 AS timestamp,
8383
* EXCEPT(date, metric, lens)
8484
FROM \`${EXPORT_CONFIG.dataset}.${tableName}\`
85-
WHERE metric = '${metric.id}'
85+
WHERE
86+
date = '${date}'
87+
AND metric = '${metric.id}'
8688
AND lens = '${lens.name}'
87-
ORDER BY date DESC
89+
ORDER BY date, client DESC
8890
`
8991
} else {
9092
throw new Error(`Unknown SQL type: ${sql.type}`)
@@ -110,7 +112,7 @@ function createReportConfig(date, metric, sql, lensName, lensSQL) {
110112
sql,
111113
lens: { name: lensName, sql: lensSQL },
112114
devRankFilter: constants.devRankFilter,
113-
tableName: `${metric.id}_${sql.type}`
115+
tableName: sql.type === 'timeseries' ? sql.type : `${metric.id}_${sql.type}`
114116
}
115117
}
116118

@@ -180,6 +182,7 @@ INSERT INTO ${EXPORT_CONFIG.dataset}.${tableName}
180182
--*/
181183
182184
SELECT
185+
DATE('${date}') AS date,
183186
'${metric.id}' AS metric,
184187
'${lens.name}' AS lens,
185188
*

0 commit comments

Comments
 (0)