Skip to content

Commit 1bd282e

Browse files
committed
Use new scores.json format
Signed-off-by: Nico Burns <[email protected]>
1 parent 4d33c95 commit 1bd282e

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

assets/js/load-chart.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ function setupChart () {
105105
const area_dropdown = document.getElementById('selected-area')
106106
const period_dropdown = document.getElementById('selected-period')
107107
const chart = new google.visualization.LineChart(node)
108-
const AREA_SCORE_OFFSET = 3
109-
let all_scores
108+
let score_data
110109

111110
Object.keys(periodRanges).forEach(date => {
112111
const selector = document.createElement('option')
@@ -116,7 +115,7 @@ function setupChart () {
116115
})
117116

118117
function update_chart () {
119-
if (!all_scores) throw new Error('scores not loaded')
118+
if (!score_data) throw new Error('scores not loaded')
120119
const area_index = +area_dropdown.value
121120
const chosen_period = period_dropdown.value
122121
const table = new google.visualization.DataTable()
@@ -134,19 +133,18 @@ function setupChart () {
134133
table.addColumn('number', 'Subtests')
135134
table.addColumn({ type: 'string', role: 'tooltip', p: { html: true } })
136135

137-
for (const scores_for_run of all_scores.scores) {
138-
const area_score = scores_for_run[area_index + AREA_SCORE_OFFSET]
139-
const [date_string, wpt_sha, browser_version] = scores_for_run
140-
const date = parseDateString(date_string)
136+
for (const run of score_data.runs) {
137+
const area_score = run.scores[area_index]
138+
const date = parseDateString(run.date)
141139
if (date < minDate) {
142140
continue
143141
}
144142
const row = [
145143
date,
146144
area_score.total_score / area_score.total_tests,
147-
toolTip(date, wpt_sha, browser_version, area_score),
145+
toolTip(date, run.wpt_revision, run.product_revision, area_score),
148146
area_score.total_subtests_passed / area_score.total_subtests,
149-
toolTip(date, wpt_sha, browser_version, area_score)
147+
toolTip(date, run.wpt_revision, run.product_revision, area_score)
150148
]
151149
table.addRow(row)
152150
}
@@ -155,15 +153,15 @@ function setupChart () {
155153

156154
fetchData
157155
.then(resp => resp.json())
158-
.then(scores => {
159-
all_scores = scores
160-
if (scores.scores.length < 60) {
156+
.then(data => {
157+
score_data = data
158+
if (score_data.runs.length < 60) {
161159
options.hAxis.format = 'dd MMM YYYY'
162160
} else {
163161
options.hAxis.format = 'MMM YYYY'
164162
}
165163

166-
for (const [index, area] of scores.focus_areas.entries()) {
164+
for (const [index, area] of score_data.focus_areas.entries()) {
167165
const selector = document.createElement('option')
168166
selector.value = index
169167
selector.textContent = area

assets/js/load-table.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
const fetchData = fetch('https://wpt.servo.org/scores-last-run.json')
22

3-
const AREA_SCORE_OFFSET = 3
4-
53
function removeChildren (parent) {
64
while (parent.firstChild) {
75
parent.removeChild(parent.firstChild)
86
}
97
return parent
108
}
119

12-
function update_table (scores) {
10+
function update_table (data) {
1311
const score_table = document.getElementById('score-table-body')
1412
removeChildren(score_table)
1513

16-
for (const [idx, area] of scores.focus_areas.entries()) {
17-
const area_score = scores.scores_last_run[idx + AREA_SCORE_OFFSET]
14+
for (const [idx, area] of data.focus_areas.entries()) {
15+
const area_score = data.last_run.scores[idx]
1816
const score = Math.floor(1000 * area_score.total_score / area_score.total_tests) / 10
1917
const subtests = Math.floor(1000 * area_score.total_subtests_passed / area_score.total_subtests) / 10
2018
score_table.insertAdjacentHTML(
@@ -30,7 +28,5 @@ function update_table (scores) {
3028

3129
fetchData
3230
.then(resp => resp.json())
33-
.then(scores => {
34-
update_table(scores)
35-
})
31+
.then(data => update_table(data))
3632

0 commit comments

Comments
 (0)