Skip to content

Commit 55adcf4

Browse files
committed
lenses path
1 parent 5637e83 commit 55adcf4

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

infra/bigquery-export/reports.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export class ReportsExporter {
66
constructor () {
77
this.bigquery = new BigQueryExport()
88
this.storage = new StorageExport()
9+
this.storagePath = 'reports/dev/' // TODO change to prod
910
}
1011

1112
// Export timeseries reports
@@ -18,7 +19,7 @@ SELECT
1819
FROM reports.${metric}_timeseries
1920
`
2021
const rows = await this.bigquery.queryResults(query)
21-
await this.storage.exportToJson(rows, metric)
22+
await this.storage.exportToJson(rows, `${this.storagePath}${metric}.json`)
2223
}
2324

2425
// Export monthly histogram report
@@ -41,6 +42,10 @@ WHERE date = '${date}'
4142
return
4243
}
4344

45+
if (exportData.lense && exportData.lense !== 'all') {
46+
this.storagePath = this.storagePath + `${exportData.lense}/`
47+
}
48+
4449
if (exportData.type === 'histogram') {
4550
await this.exportHistogram(exportData)
4651
} else if (exportData.type === 'timeseries') {

infra/bigquery-export/storage.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@ const storage = new Storage()
77
export class StorageExport {
88
constructor (bucket = 'httparchive') {
99
this.bucket = bucket
10-
this.storagePath = 'reports/dev/' // TODO change to prod
1110
this.stream = new Readable({
1211
objectMode: true,
1312
read () {}
1413
})
1514
}
1615

1716
async exportToJson (data, fileName) {
18-
fileName = this.storagePath + fileName + '.json'
19-
2017
const bucket = storage.bucket(this.bucket)
2118
const file = bucket.file(fileName)
2219

0 commit comments

Comments
 (0)