From a64b13acd029c578800ad9e092c3599c9ac50bc4 Mon Sep 17 00:00:00 2001 From: "Glitch (glitch-hello-node)" Date: Sun, 14 Nov 2021 07:00:52 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=A6=F0=9F=8F=8E=20Checkpoint=20./publi?= =?UTF-8?q?c/index.js:1954897/34051?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db.csv | 19 +++++++++++++++++++ public/index.js | 16 ++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/db.csv b/db.csv index 5a1751d..637c045 100644 --- a/db.csv +++ b/db.csv @@ -150,3 +150,22 @@ ECSW,1636870263236,3 ECSW,1636870280400,3 ECSW,1636870298164,3 ECSW,1636870316252,3 +ECSW,1636872887382,2 +ECSW,1636872907445,3 +ECSW,1636872925228,3 +ECSW,1636872943180,3 +ECSW,1636872971435,4 +ECSW,1636872989172,4 +ECSW,1636873007195,4 +ECSW,1636873024462,3 +ECSW,1636873043241,4 +ECSW,1636873065227,4 +ECSW,1636873083327,4 +ECSW,1636873101359,4 +ECSW,1636873119248,4 +ECSW,1636873139178,4 +ECSW,1636873156488,4 +ECSW,1636873174467,4 +ECSW,1636873194206,3 +ECSW,1636873221180,3 +ECSW,1636873239096,3 diff --git a/public/index.js b/public/index.js index 2907204..618d2aa 100644 --- a/public/index.js +++ b/public/index.js @@ -68,17 +68,17 @@ fetch('/db.csv').then(res => res.text()).then(text => { return { loc, time: new Date(+time), count: parseInt(count) } }) - const ecss = data.filter(d => d.loc === 'ecss') + const ecsw = data.filter(d => d.loc === 'ECSW') - console.log(ecss) + console.log(ecsw) - const avg = ecss.reduce((acc, v) => acc + v.count, 0) / ecss.length - const current = ecss[ecss.length - 1].count + const avg = ecsw.reduce((acc, v) => acc + v.count, 0) / ecsw.length + const current = ecsw[ecsw.length - 1].count const delta = current - avg - const color = delta > 0 ? '#ff0000' : '#00ff00' - buildings.ECSW.poly.setStyle({ - color: `#${color}` - }) + const busy = delta > 0 + const color = busy ? '#ff0000' : '#00ff00' + buildings.ECSW.poly.setStyle({ color }) + console.log({avg, current, delta, color}) }) async function displayCard(id) {