From 0bebcf6bfddc8f738b96dad266af504b0c3c7f7d Mon Sep 17 00:00:00 2001 From: tmont Date: Tue, 28 Apr 2020 18:17:03 -0700 Subject: [PATCH] relabeled stuff --- tmpl/master.pug | 51 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/tmpl/master.pug b/tmpl/master.pug index 50d11d7..d82aef2 100644 --- a/tmpl/master.pug +++ b/tmpl/master.pug @@ -155,14 +155,13 @@ html th(data-col="name"): +sortableLinks("name")= label if hasPopulation th.text-center(data-col="population"): +sortableLinks("population") Population - th.text-center(data-col="total"): +sortableLinks("total") Deaths - if hasPopulation - th.text-center(data-col="million"): +sortableLinks("million") …/1M - th.text-center.sorted(data-col="yesterday"): +sortableLinks("yesterday") …since yesterday - th.text-center(data-col="week"): +sortableLinks("week") …since last week - th.text-center(data-col="month"): +sortableLinks("month") …month-to-date - th.text-center(data-col="growth"): +sortableLinks("growth") …growth rate - th.text-center Last 14 days + th.text-center(data-col="million"): +sortableLinks("million") per 1M + th.text-center(data-col="total"): +sortableLinks("total") Total + th.text-center.sorted(data-col="today"): +sortableLinks("today") Today + th.text-center(data-col="last7"): +sortableLinks("last7") Last 7 days + th.text-center(data-col="last30"): +sortableLinks("last30") Last 30 days + th.text-center(data-col="growth"): +sortableLinks("growth") Growth Rate + th.text-center Trend - items.sort((a, b) => { @@ -176,31 +175,33 @@ html }); tbody: each item, i in items - - const yesterday = item.timeSeriesDaily[item.timeSeriesDaily.length - 1].delta || 0; - - const lastWeek = item.timeSeriesDaily[item.timeSeriesDaily.length - 1].value - item.timeSeriesDaily[item.timeSeriesDaily.length - 7].value; - - const lastMonth = item.timeSeriesMonthly[item.timeSeriesMonthly.length - 1].delta || 0; + - + const getValue = offset => (item.timeSeriesDaily[item.timeSeriesDaily.length - offset] || {}).value || 0; + const getDelta = offset => (item.timeSeriesDaily[item.timeSeriesDaily.length - offset] || {}).delta || 0; + const today = getDelta(1); + const last7 = getValue(1) - getValue(7); + const last30 = getValue(1) - getValue(30); tr( id=("row-" + item.safeName) data-name=item.name data-population=item.population data-total=item.total data-million=item.deathsPerMillion - data-yesterday=yesterday - data-week=lastWeek - data-month=lastMonth + data-today=today + data-last7=last7 + data-last30=last30 data-growth=item.deathGrowthRate ) td.sort-order= i + 1 td: +renderItemName(item) if hasPopulation - td.text-right: +formatNumber(item.population) - td.text-right: +formatNumber(item.total) - if hasPopulation - td.text-right: +formatNumber(Math.round(item.deathsPerMillion)) - td.text-right.sorted: +formatNumber(yesterday) - td.text-right: +formatNumber(lastWeek) - td.text-right: +formatNumber(lastMonth) - td.text-right= Number(item.deathGrowthRate * 100).toFixed(2) + '%' + td.text-right: code: +formatNumber(item.population) + td.text-right: code: +formatNumber(Math.round(item.deathsPerMillion)) + td.text-right: code: +formatNumber(item.total) + td.text-right.sorted: code: +formatNumber(today) + td.text-right: code: +formatNumber(last7) + td.text-right: code: +formatNumber(last30) + td.text-right: code= Number(item.deathGrowthRate * 100).toFixed(2) + '%' td canvas.mx-auto(id="sparkline-" + i width="200" height="50") script. @@ -305,9 +306,9 @@ html resortTable('name'); break; case 'total': - case 'yesterday': - case 'week': - case 'month': + case 'today': + case 'last7': + case 'last30': case 'population': case 'million': case 'growth':