2022-01-01 21:50:29 -05:00

42 lines
1.2 KiB
JavaScript

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))
}