diff --git a/webapp/compat_2021_handler.go b/webapp/compat_2021_handler.go deleted file mode 100644 index acbe6940d9f..00000000000 --- a/webapp/compat_2021_handler.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2021 The WPT Dashboard Project. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package webapp - -import ( - "net/http" - "github.com/web-platform-tests/wpt.fyi/shared" -) - -type compat2021Data struct { - Embedded bool -} - -// compat2021Handler handles GET requests to /compat2021 -func compat2021Handler(w http.ResponseWriter, r *http.Request) { - if r.Method != "GET" { - http.Error(w, "Only GET is supported.", http.StatusMethodNotAllowed) - return - } - - q := r.URL.Query() - embedded, err := shared.ParseBooleanParam(q, "embedded") - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - data := compat2021Data{ - Embedded: embedded != nil && *embedded, - } - RenderTemplate(w, r, "compat-2021.html", data) -} diff --git a/webapp/components/interop-2022.js b/webapp/components/interop.js similarity index 67% rename from webapp/components/interop-2022.js rename to webapp/components/interop.js index d104d9f638c..6e95397cb38 100644 --- a/webapp/components/interop-2022.js +++ b/webapp/components/interop.js @@ -11,110 +11,25 @@ import '../node_modules/@polymer/paper-input/paper-input.js'; import '../node_modules/@polymer/polymer/lib/elements/dom-if.js'; import { html, PolymerElement } from '../node_modules/@polymer/polymer/polymer-element.js'; import {CountUp} from 'https://unpkg.com/countup.js@2.0.8/dist/countUp.js'; +import PARAMS_BY_YEAR from '../static/interop-data.json' assert {type: 'json'}; -const GITHUB_URL_PREFIX = 'https://raw.githubusercontent.com/web-platform-tests/results-analysis/gh-pages/data/interop-2022'; - -const SUMMARY_FEATURE_NAME = 'summary'; - -const FEATURES = { - 'interop-2021-aspect-ratio': { - description: 'Aspect Ratio', - mdn: 'https://developer.mozilla.org/docs/Web/CSS/aspect-ratio', - spec: 'https://drafts.csswg.org/css-sizing/#aspect-ratio', - tests: '/results/?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2021-aspect-ratio', - }, - 'interop-2021-flexbox': { - description: 'Flexbox', - mdn: 'https://developer.mozilla.org/docs/Learn/CSS/CSS_layout/Flexbox', - spec: 'https://drafts.csswg.org/css-flexbox/', - tests: '/results/css/css-flexbox?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2021-flexbox', - }, - 'interop-2021-grid': { - description: 'Grid', - mdn: 'https://developer.mozilla.org/docs/Web/CSS/grid', - spec: 'https://drafts.csswg.org/css-grid-1/', - tests: '/results/css/css-grid?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2021-grid', - }, - 'interop-2021-position-sticky': { - description: 'Sticky Positioning', - mdn: 'https://developer.mozilla.org/docs/Web/CSS/position', - spec: 'https://drafts.csswg.org/css-position/#position-property', - tests: '/results/css/css-position/sticky?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2021-position-sticky', - }, - 'interop-2021-transforms': { - description: 'Transforms', - mdn: 'https://developer.mozilla.org/docs/Web/CSS/transform', - spec: 'https://drafts.csswg.org/css-transforms/', - tests: '/results/css/css-transforms?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2021-transforms', - }, - 'interop-2022-cascade': { - description: 'Cascade Layers', - mdn: 'https://developer.mozilla.org/docs/Web/CSS/@layer', - spec: 'https://drafts.csswg.org/css-cascade/#layering', - tests: '/results/css/css-cascade?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2022-cascade', - }, - 'interop-2022-color': { - description: 'Color Spaces and Functions', - mdn: 'https://developer.mozilla.org/docs/Web/CSS/color_value', - spec: 'https://drafts.csswg.org/css-color/', - tests: '/results/css/css-color?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2022-color', - }, - 'interop-2022-contain': { - description: 'Containment', - mdn: 'https://developer.mozilla.org/docs/Web/CSS/contain', - spec: 'https://drafts.csswg.org/css-contain/#contain-property', - tests: '/results/css/css-contain?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2022-contain', - }, - 'interop-2022-dialog': { - description: 'Dialog Element', - mdn: 'https://developer.mozilla.org/docs/Web/HTML/Element/dialog', - spec: 'https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element', - tests: '/results/?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2022-dialog', - }, - 'interop-2022-forms': { - description: 'Forms', - mdn: 'https://developer.mozilla.org/docs/Web/HTML/Element/form', - spec: 'https://html.spec.whatwg.org/multipage/forms.html#the-form-element', - tests: '/results/?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2022-forms', - }, - 'interop-2022-scrolling': { - description: 'Scrolling', - mdn: 'https://developer.mozilla.org/docs/Web/CSS/overflow', - spec: 'https://drafts.csswg.org/css-overflow/#propdef-overflow', - tests: '/results/css?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2022-scrolling', - }, - 'interop-2022-subgrid': { - description: 'Subgrid', - mdn: 'https://developer.mozilla.org/docs/Web/CSS/CSS_Grid_Layout/Subgrid', - spec: 'https://drafts.csswg.org/css-grid-2/#subgrids', - tests: '/results/css/css-grid/subgrid?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2022-subgrid', - }, - 'interop-2022-text': { - description: 'Typography and Encodings', - mdn: '', - spec: '', - tests: '/results/?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2022-text', - }, - 'interop-2022-viewport': { - description: 'Viewport Units', - mdn: '', - spec: 'https://drafts.csswg.org/css-values/#viewport-relative-units', - tests: '/results/css/css-values?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2022-viewport', - }, - 'interop-2022-webcompat': { - description: 'Web Compat', - mdn: '', - spec: '', - tests: '/results/?label=experimental&label=master&product=chrome&product=firefox&product=safari&aligned&view=interop&q=label%3Ainterop-2022-webcompat', - }, -}; - -// Interop2022DataManager encapsulates the loading of the CSV data that backs -// both the summary scores and graphs shown on the Interop 2022 dashboard. It +// InteropDataManager encapsulates the loading of the CSV data that backs +// both the summary scores and graphs shown on the Interop dashboard. It // fetches the CSV data, processes it into sets of datatables, and then caches // those tables for later use by the dashboard. -class Interop2022DataManager { - constructor() { +class InteropDataManager { + constructor(year) { + // prepare all year-specific info for reference. + this.year = year; + const yearInfo = PARAMS_BY_YEAR[year]; + this.focusAreas = yearInfo.focus_areas; + this.summaryFeatureName = yearInfo.summary_feature_name; + this.csvURL = yearInfo.csv_url; + this.tableSections = yearInfo.table_sections; + this.prose = yearInfo.prose; + this.matrixURL = yearInfo.matrix_url; + this.issueURL = yearInfo.issue_url; + this._dataLoaded = load().then(() => { return Promise.all([this._loadCsv('stable'), this._loadCsv('experimental')]); }); @@ -140,7 +55,8 @@ class Interop2022DataManager { const dataTables = stable ? this.stableDatatables : this.experimentalDatatables; const scores = [{}, {}, {}]; - for (const feature of [SUMMARY_FEATURE_NAME, ...Object.keys(FEATURES)]) { + for (const feature of [ + this.summaryFeatureName, ...Object.keys(this.focusAreas)]) { const dataTable = dataTables.get(feature); // Assumption: The rows are ordered by dates with the most recent entry last. const lastRowIndex = dataTable.getNumberOfRows() - 1; @@ -169,10 +85,11 @@ class Interop2022DataManager { // ultimately set either this.stableDatatables or this.experimentalDatatables // with a map of {feature name --> datatable}. async _loadCsv(label) { - const url = `${GITHUB_URL_PREFIX}/interop-2022-${label}.csv`; + const url = this.csvURL.replace('{stable|experimental}', label); const csvLines = await fetchCsvContents(url); - const features = [SUMMARY_FEATURE_NAME, ...Object.keys(FEATURES)]; + const features = [this.summaryFeatureName, + ...Object.keys(this.focusAreas)]; const dataTables = new Map(features.map(feature => { const dataTable = new window.google.visualization.DataTable(); dataTable.addColumn('date', 'Date'); @@ -193,14 +110,25 @@ class Interop2022DataManager { 'Firefox', 'Safari', ]; - + const focusAreaLabels = Object.keys(this.focusAreas); // We store a lookup table of browser versions to help with the // 'Show browser changelog' tooltip action. const browserVersions = [[], [], []]; + const numFocusAreas = focusAreaLabels.length; + + // Extract the label headers in order. + const headers = csvLines[0] + .split(',') + // Ignore the date and browser version. + .slice(2, 2 + numFocusAreas) + // Remove the browser prefix (e.g. chrome-css-grid becomes css-grid). + .map(label => label.slice(label.indexOf('-') + 1)); + + // Drop the headers to prepare for aggregation. + csvLines.shift(); + csvLines.forEach(line => { - // We control the CSV data source, so are quite lazy with parsing it. - // // The format is: // date, [browser-version, browser-feature-a, browser-feature-b, ...]+ const csvValues = line.split(','); @@ -217,15 +145,21 @@ class Interop2022DataManager { // Now handle each of the browsers. For each there is a version column, // then the scores for each of the features. - for (let i = 1; i < csvValues.length; i += 16) { - const browserIdx = Math.floor(i / 16); + for (let i = 1; i < csvValues.length; i += (numFocusAreas + 1)) { + const browserIdx = Math.floor(i / (numFocusAreas + 1)); const browserName = tooltipBrowserNames[browserIdx]; const version = csvValues[i]; browserVersions[browserIdx].push(version); let testScore = 0; - Object.keys(FEATURES).forEach((feature, j) => { - const score = parseInt(csvValues[i + 1 + j]); + headers.forEach((feature, j) => { + let score = 0; + // 2021 scores are formatted as a decimal rather than a number 0-1000. + if (this.year === '2021') { + score = parseInt(parseFloat(csvValues[i + 1 + j]) * 1000); + } else { + score = parseInt(csvValues[i + 1 + j]); + } if (!(score >= 0 && score <= 1000)) { throw new Error(`Expected score in 0-1000 range, got ${score}`); } @@ -236,14 +170,17 @@ class Interop2022DataManager { testScore += score; }); - // TODO: get the investigation score at this date. - const investigationScore = 0; + let summaryScore = testScore / numFocusAreas; - const summaryScore = Math.floor((0.9 * testScore) / 15 + (0.1 * investigationScore)); + // TODO: get the investigation score at this date. + if (this.year === '2022') { + summaryScore = summaryScore * 0.9; + } + summaryScore = Math.floor(summaryScore); const summaryTooltip = this.createTooltip(browserName, version, summaryScore); - newRows.get(SUMMARY_FEATURE_NAME).push(summaryScore / 1000); - newRows.get(SUMMARY_FEATURE_NAME).push(summaryTooltip); + newRows.get(this.summaryFeatureName).push(summaryScore / 1000); + newRows.get(this.summaryFeatureName).push(summaryTooltip); } // Push the new rows onto the corresponding datatable. @@ -268,12 +205,22 @@ class Interop2022DataManager { // with one decimal point. return `${score / 10}% passing \n${browser} ${version}`; } + + // Data Manager holds all year-specific properties. This method is a generic + // accessor for those properties. + getYearProp(prop) { + if (prop in this) { + return this[prop]; + } + return ''; + } } -// Interop2022 is a custom element that holds the overall interop-2022 dashboard. + +// InteropDashboard is a custom element that holds the overall interop dashboard. // The dashboard breaks down into top-level summary scores, a small description, // graphs per feature, and a table of currently tracked tests. -class Interop2022 extends PolymerElement { +class InteropDashboard extends PolymerElement { static get template() { return html` -

Interop 2022 Dashboard

+

Interop [[year]] Dashboard

-

- These scores represent how browser engines are doing in 15 focus areas - and 3 joint investigation efforts. -

+

[[getYearProp('prose')]]

Stable Experimental
- +
- - -
How are these scores calculated?
2022 Focus Areas (60%) - -