Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions assets/js/load-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ function setupChart () {
const area_dropdown = document.getElementById('selected-area')
const period_dropdown = document.getElementById('selected-period')
const chart = new google.visualization.LineChart(node)
const AREA_SCORE_OFFSET = 3
let all_scores
let score_data

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

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

for (const scores_for_run of all_scores.scores) {
const area_score = scores_for_run[area_index + AREA_SCORE_OFFSET]
const [date_string, wpt_sha, browser_version] = scores_for_run
const date = parseDateString(date_string)
for (const run of score_data.runs) {
const area_score = run.scores[area_index]
const date = parseDateString(run.date)
if (date < minDate) {
continue
}
const row = [
date,
area_score.total_score / area_score.total_tests,
toolTip(date, wpt_sha, browser_version, area_score),
toolTip(date, run.wpt_revision, run.servo_revision, area_score),
area_score.total_subtests_passed / area_score.total_subtests,
toolTip(date, wpt_sha, browser_version, area_score)
toolTip(date, run.wpt_revision, run.servo_revision, area_score)
]
table.addRow(row)
}
Expand All @@ -155,15 +153,15 @@ function setupChart () {

fetchData
.then(resp => resp.json())
.then(scores => {
all_scores = scores
if (scores.scores.length < 60) {
.then(data => {
score_data = data
if (score_data.runs.length < 60) {
options.hAxis.format = 'dd MMM YYYY'
} else {
options.hAxis.format = 'MMM YYYY'
}

for (const [index, area] of scores.focus_areas.entries()) {
for (const [index, area] of score_data.focus_areas.entries()) {
const selector = document.createElement('option')
selector.value = index
selector.textContent = area
Expand Down
12 changes: 4 additions & 8 deletions assets/js/load-table.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
const fetchData = fetch('https://wpt.servo.org/scores-last-run.json')

const AREA_SCORE_OFFSET = 3

function removeChildren (parent) {
while (parent.firstChild) {
parent.removeChild(parent.firstChild)
}
return parent
}

function update_table (scores) {
function update_table (data) {
const score_table = document.getElementById('score-table-body')
removeChildren(score_table)

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

fetchData
.then(resp => resp.json())
.then(scores => {
update_table(scores)
})
.then(data => update_table(data))

Loading