Add summary section to index.

This commit is contained in:
Joshua Bemenderfer
2022-01-01 21:50:26 -05:00
parent 94018b70ec
commit b3289258e3
27 changed files with 593 additions and 88 deletions

41
data/parser/summary.js Normal file
View File

@@ -0,0 +1,41 @@
import mkdirp from 'mkdirp'
import path from 'path'
import fsp from 'fs/promises'
async function readJSON(file) {
return JSON.parse(await fsp.readFile(file, 'utf-8'))
}
export default async function process () {
const testing = await readJSON('./public/data/overall/testing/by-county/-- All --.json')
const cases = await readJSON('./public/data/overall/cases/by-county/-- All --.json')
const hospitalizations = await readJSON('./public/data/overall/hospitalizations/by-county/-- All --.json')
const deaths = await readJSON('./public/data/overall/deaths/by-county/-- All --.json')
const summary = {
last_report_date: testing.rows.at(-1)[0],
testing: {
headers: testing.headers,
current: testing.rows.at(-1),
prev: testing.rows.at(-2),
},
cases: {
headers: cases.headers,
current: cases.rows.at(-1),
prev: cases.rows.at(-2),
},
hospitalizations: {
headers: hospitalizations.headers,
current: hospitalizations.rows.at(-1),
prev: hospitalizations.rows.at(-2),
},
deaths: {
headers: deaths.headers,
current: deaths.rows.at(-1),
prev: deaths.rows.at(-2),
}
}
await fsp.writeFile('./public/data/summary.json', JSON.stringify(summary))
}