Skip to content

Commit db2b77e

Browse files
authored
Use object rather than array for scores.json entries (#67)
* Use an object rather than heterogeneous array for scores.json entries Signed-off-by: Nico Burns <[email protected]> * Rename "scores" to "runs" --------- Signed-off-by: Nico Burns <[email protected]>
1 parent d6ff6c5 commit db2b77e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async function add_run (runs_dir, chunks_dir, date) {
7070
async function recalc_scores (runs_dir) {
7171
console.log(`Calculating scores for ${runs_dir} directory...`)
7272

73-
const scores = []
73+
const run_results = []
7474
console.log('Enumerating runs')
7575
const all_runs = await all_runs_sorted(runs_dir)
7676
const run_count = all_runs.length
@@ -84,17 +84,17 @@ async function recalc_scores (runs_dir) {
8484
const run = await read_compressed(`./${runs_dir}/${r}`)
8585
console.log(`Calculating score for run ${runs_dir}/${r} (${i}/${run_count})`)
8686
const score = score_run(run, new_run, test_to_areas)
87-
const row = [
87+
const row = {
8888
date,
89-
run.run_info.revision.substring(0, 9),
90-
run.run_info.browser_version,
91-
...score
92-
]
89+
wpt_revision: run.run_info.revision.substring(0, 9),
90+
product_revision: run.run_info.browser_version,
91+
scores: score
92+
}
9393

94-
scores.push(row)
94+
run_results.push(row)
9595
}
9696

97-
return scores
97+
return run_results
9898
}
9999

100100
async function main () {
@@ -109,18 +109,18 @@ async function main () {
109109
await add_run('runs-2020', chunks, date)
110110
}
111111

112-
const scores = await recalc_scores('runs-2020')
113-
const scores_last_run = scores[scores.length - 1]
112+
const run_results = await recalc_scores('runs-2020')
113+
const last_run = run_results[run_results.length - 1]
114114

115115
const focus_areas = get_focus_areas()
116116

117117
console.log('Writing site/scores.json')
118118
await mkdir('./site', { recursive: true })
119119
write_json_file(
120-
'./site/scores.json', { focus_areas, scores })
120+
'./site/scores.json', { focus_areas, runs: run_results })
121121
console.log('Writing site/scores-last-run.json')
122122
write_json_file(
123-
'./site/scores-last-run.json', { focus_areas, scores_last_run })
123+
'./site/scores-last-run.json', { focus_areas, last_run })
124124

125125
console.log('Done')
126126
}

0 commit comments

Comments
 (0)