From ea577ea2f9d5519dcdd8c124e3f78bd3ccc7c726 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Thu, 17 Jul 2025 12:43:06 +0100 Subject: [PATCH 1/2] Use an object rather than heterogeneous array for scores.json entries Signed-off-by: Nico Burns --- index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 63aae52..dca4f4f 100644 --- a/index.js +++ b/index.js @@ -84,12 +84,12 @@ async function recalc_scores (runs_dir) { const run = await read_compressed(`./${runs_dir}/${r}`) console.log(`Calculating score for run ${runs_dir}/${r} (${i}/${run_count})`) const score = score_run(run, new_run, test_to_areas) - const row = [ + const row = { date, - run.run_info.revision.substring(0, 9), - run.run_info.browser_version, - ...score - ] + wpt_revision: run.run_info.revision.substring(0, 9), + product_revision: run.run_info.browser_version, + scores: score + } scores.push(row) } From 9036ad8efc1f80e4d6b6f21317fc0d5f0aafc2ef Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Thu, 17 Jul 2025 13:57:48 +0100 Subject: [PATCH 2/2] Rename "scores" to "runs" --- index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index dca4f4f..ad544c1 100644 --- a/index.js +++ b/index.js @@ -70,7 +70,7 @@ async function add_run (runs_dir, chunks_dir, date) { async function recalc_scores (runs_dir) { console.log(`Calculating scores for ${runs_dir} directory...`) - const scores = [] + const run_results = [] console.log('Enumerating runs') const all_runs = await all_runs_sorted(runs_dir) const run_count = all_runs.length @@ -91,10 +91,10 @@ async function recalc_scores (runs_dir) { scores: score } - scores.push(row) + run_results.push(row) } - return scores + return run_results } async function main () { @@ -109,18 +109,18 @@ async function main () { await add_run('runs-2020', chunks, date) } - const scores = await recalc_scores('runs-2020') - const scores_last_run = scores[scores.length - 1] + const run_results = await recalc_scores('runs-2020') + const last_run = run_results[run_results.length - 1] const focus_areas = get_focus_areas() console.log('Writing site/scores.json') await mkdir('./site', { recursive: true }) write_json_file( - './site/scores.json', { focus_areas, scores }) + './site/scores.json', { focus_areas, runs: run_results }) console.log('Writing site/scores-last-run.json') write_json_file( - './site/scores-last-run.json', { focus_areas, scores_last_run }) + './site/scores-last-run.json', { focus_areas, last_run }) console.log('Done') }