Skip to content

Commit 390269b

Browse files
committed
update
1 parent 53c133e commit 390269b

File tree

3 files changed

+16
-102
lines changed

3 files changed

+16
-102
lines changed

includes/reports.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ WITH pages AS (
1111
SELECT
1212
date,
1313
client,
14-
CAST(FLOOR(INT64(summary.bytesTotal) / 1024 / 100) * 100 AS INT64) AS bin
14+
CAST(FLOOR(FLOAT64(summary.bytesTotal) / 1024 / 100) * 100 AS INT64) AS bin
1515
FROM crawl.pages
1616
WHERE
1717
date = '${params.date}'
1818
${params.lens.sql}
1919
AND is_root_page
20-
AND INT64(summary.bytesTotal) > 0
20+
AND FLOAT64(summary.bytesTotal) > 0
2121
)
2222
2323
SELECT
@@ -32,15 +32,14 @@ FROM (
3232
*,
3333
COUNT(0) AS volume
3434
FROM pages
35+
WHERE bin IS NOT NULL
3536
GROUP BY
3637
date,
3738
client,
3839
bin
39-
HAVING bin IS NOT NULL
4040
)
4141
)
4242
ORDER BY
43-
date,
4443
bin,
4544
client
4645
`)
@@ -52,7 +51,7 @@ WITH pages AS (
5251
SELECT
5352
date,
5453
client,
55-
INT64(summary.bytesTotal) AS bytesTotal
54+
FLOAT64(summary.bytesTotal) AS bytesTotal
5655
FROM crawl.pages
5756
WHERE
5857
date = '${params.date}'
@@ -75,6 +74,9 @@ GROUP BY
7574
date,
7675
client,
7776
timestamp
77+
ORDER BY
78+
date,
79+
client
7880
`)
7981
}
8082
]
@@ -94,12 +96,12 @@ const lenses = {
9496
}
9597

9698
class HTTPArchiveReports {
97-
constructor () {
99+
constructor() {
98100
this.config = config
99101
this.lenses = lenses
100102
}
101103

102-
listReports () {
104+
listReports() {
103105
const reportIds = this.config._reports
104106

105107
const reports = reportIds.map(reportId => {
@@ -110,15 +112,15 @@ class HTTPArchiveReports {
110112
return reports
111113
}
112114

113-
getReport (reportId) {
115+
getReport(reportId) {
114116
const report = this.config[reportId]
115117
return {
116118
id: reportId,
117119
...report
118120
}
119121
}
120122

121-
listMetrics (reportId) {
123+
listMetrics(reportId) {
122124
if (reportId === undefined) {
123125
const metrics = Object.keys(this.config._metrics).map(metricId => {
124126
const metric = this.getMetric(metricId)
@@ -139,7 +141,7 @@ class HTTPArchiveReports {
139141
}
140142
}
141143

142-
getMetric (metricId) {
144+
getMetric(metricId) {
143145
const metric = this.config._metrics[metricId]
144146

145147
return {

infra/bigquery-export/reports.js

Lines changed: 0 additions & 91 deletions
This file was deleted.

infra/bigquery-export/storage.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { Storage } from '@google-cloud/storage'
2+
import { BigQueryExport } from './bigquery.js'
23
import { Readable } from 'stream'
34
import zlib from 'zlib'
45

6+
const bigquery = new BigQueryExport()
57
const storage = new Storage()
68

79
export class StorageUpload {
@@ -13,7 +15,8 @@ export class StorageUpload {
1315
})
1416
}
1517

16-
async exportToJson (data, fileName) {
18+
async exportToJson (query, fileName) {
19+
const data = await bigquery.queryResults(query)
1720
const bucket = storage.bucket(this.bucket)
1821
const file = bucket.file(fileName)
1922

0 commit comments

Comments
 (0)