-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess
executable file
·29 lines (26 loc) · 992 Bytes
/
process
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env node
const fs = require('fs');
const EXPORT_TO = '/tmp/all_versions_exported'
const dataset = [];
fs.readdir(EXPORT_TO, (err, files) => {
files.forEach(file => {
// 0018.25-Mar-2022.87e921c8ab35c52523049a9fa05abd395a34cc09.us-central1.json
const match = /(?<num>\d*)\.(?<date>[^.]*)\.(?<commit>[^.]*)\.(?<name>[^.]*)/.exec(file)
const num = match.groups.num;
const date = match.groups.date;
const commit = match.groups.commit;
const name = match.groups.name;
const data = JSON.parse(fs.readFileSync(EXPORT_TO + '/' + file))
Object.keys(data.browsers).forEach(browser => data.browsers[browser].pages.forEach(page => {
if (page.url.startsWith("https://"))
dataset.push({
namespace: browser,
url: page.url,
date,
name,
...page.metrics
})
}))
});
fs.writeFileSync("summary/usage.json", JSON.stringify(dataset, null, 2))
});