Skip to content

Commit

Permalink
lenses path
Browse files Browse the repository at this point in the history
  • Loading branch information
max-ostapenko committed Jan 7, 2025
1 parent 5637e83 commit 55adcf4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 6 additions & 1 deletion infra/bigquery-export/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class ReportsExporter {
constructor () {
this.bigquery = new BigQueryExport()
this.storage = new StorageExport()
this.storagePath = 'reports/dev/' // TODO change to prod
}

// Export timeseries reports
Expand All @@ -18,7 +19,7 @@ SELECT
FROM reports.${metric}_timeseries
`
const rows = await this.bigquery.queryResults(query)
await this.storage.exportToJson(rows, metric)
await this.storage.exportToJson(rows, `${this.storagePath}${metric}.json`)
}

// Export monthly histogram report
Expand All @@ -41,6 +42,10 @@ WHERE date = '${date}'
return
}

if (exportData.lense && exportData.lense !== 'all') {
this.storagePath = this.storagePath + `${exportData.lense}/`
}

if (exportData.type === 'histogram') {
await this.exportHistogram(exportData)
} else if (exportData.type === 'timeseries') {
Expand Down
3 changes: 0 additions & 3 deletions infra/bigquery-export/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ const storage = new Storage()
export class StorageExport {
constructor (bucket = 'httparchive') {
this.bucket = bucket
this.storagePath = 'reports/dev/' // TODO change to prod
this.stream = new Readable({
objectMode: true,
read () {}
})
}

async exportToJson (data, fileName) {
fileName = this.storagePath + fileName + '.json'

const bucket = storage.bucket(this.bucket)
const file = bucket.file(fileName)

Expand Down

0 comments on commit 55adcf4

Please sign in to comment.