Add summary section to index.
This commit is contained in:
@@ -11,6 +11,8 @@ import OverallDeaths from './parser/overall/deaths.js'
|
||||
import RiskAge from './parser/risk/age.js'
|
||||
import RiskHealthConditions from './parser/risk/health-conditions.js'
|
||||
|
||||
import Summary from './parser/summary.js'
|
||||
|
||||
async function main() {
|
||||
const sources = await fg(['./data/raw/*.zip'])
|
||||
sources.sort()
|
||||
@@ -29,6 +31,8 @@ async function main() {
|
||||
|
||||
await RiskAge(zips)
|
||||
await RiskHealthConditions(zips)
|
||||
|
||||
await Summary()
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
41
data/parser/summary.js
Normal file
41
data/parser/summary.js
Normal 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))
|
||||
}
|
||||
Reference in New Issue
Block a user