From 8abc90e1dc3e0a899d133e24deb589f24e840017 Mon Sep 17 00:00:00 2001 From: Jim Bumgardner Date: Tue, 19 Dec 2023 14:58:50 -0800 Subject: [PATCH] Added performance measurements. --- .eleventy.js | 2 +- docs/site/_data/performance.js | 28 ++++++++++++++++++++++++++++ docs/site/_includes/par-scores.njk | 8 ++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 docs/site/_data/performance.js diff --git a/.eleventy.js b/.eleventy.js index f86e1bcb..7102680f 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -118,7 +118,7 @@ module.exports = function (eleventyConfig) { } // if inputPath doesn't exist, log it if (fs.existsSync(inputPath)) { - console.log(" will score -> "+inputPath); + // console.log(" will score -> "+inputPath); fileList.push({outputPath:outputPath, inputPath:inputPath}); // item.inputPath = inputPath; // item.outputPath = outputPath; diff --git a/docs/site/_data/performance.js b/docs/site/_data/performance.js new file mode 100644 index 00000000..46d463d7 --- /dev/null +++ b/docs/site/_data/performance.js @@ -0,0 +1,28 @@ +module.exports = function () { + return new Promise(async (resolve, reject) => { + // console.log("FETCHING performance data"); + // console.trace(); + // see details about this API in readme + const perfAudits = await fetch("https://18ap0iejha.execute-api.us-west-1.amazonaws.com/?site=hub.innovation.ca.gov"); + const perfData = await perfAudits.json(); + let pagePerformanceData = {}; + perfData.forEach(item => { + if(item.performance) { + pagePerformanceData[item.pageURL.replace('https://hub.innovation.ca.gov/','/')] = { + lighthouse: { + performance: item.performance, + accessibility: 1 + } + } + } + if(item.accessibility) { + pagePerformanceData[item.pageURL.replace('https://hub.innovation.ca.gov/','/')].lighthouse.accessibility = item.accessibility; + } + }) + + console.log(pagePerformanceData); + resolve(pagePerformanceData); + }); +}; + + diff --git a/docs/site/_includes/par-scores.njk b/docs/site/_includes/par-scores.njk index 3109ca10..60692c43 100644 --- a/docs/site/_includes/par-scores.njk +++ b/docs/site/_includes/par-scores.njk @@ -2,20 +2,24 @@

ODI grades the reading level, performance, and accessibility of all our webpages. Here are this page’s scores as of the last update:

+ {% if performance[page.url].lighthouse.performance %} - 50 + {{performance[page.url].lighthouse.performance * 100}} Performance Why is performance important + {% endif %} + {% if performance[page.url].lighthouse.accessibility %} - 50 + {{performance[page.url].lighthouse.accessibility * 100}} Accessibility Why is accessibility important + {% endif %} {% if readability[page.url].readability.ari %}