Skip to content

Commit

Permalink
feat: add "rd" area code
Browse files Browse the repository at this point in the history
  • Loading branch information
kkkrist committed Jun 30, 2021
1 parent 3e2abb1 commit 0bba3a5
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 28 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Currently the following regions are supported:
- Leipzig
- Kreis Herzogtum Lauenburg
- Kreis Plön
- Kreis Rendsburg-Eckernförde
- Kreis Schleswig-Flensburg
- Kreis Stormarn

Expand Down
3 changes: 2 additions & 1 deletion packages/crawler/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ const upsert = stats =>

Promise.allSettled([
require('./fl2')(),
require('./ks')(),
require('./l')(),
require('./lg')(),
require('./ks')(),
require('./od')(),
require('./plö')(),
require('./rd')(),
require('./row')(),
require('./rz')(),
require('./sl')()
Expand Down
54 changes: 54 additions & 0 deletions packages/crawler/lib/rd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'use strict'

const fetch = require('node-fetch')
const fetchOptions = require('./fetch-options.json')

module.exports = () =>
Promise.all([
fetch('https://covid19dashboardrdeck.aco/daten/update.js', fetchOptions),
fetch('https://covid19dashboardrdeck.aco/daten/dash.js', fetchOptions)
])
.then(responses => Promise.all(responses.map(res => res.text())))
.then(texts => {
const text = texts.join('')

const matches = {
activeMatch: text.match(/todayActivInfected\s?=\s?'(\d+)'/),
dateMatch: text.match(
/lastUpdate\s?=\s?'(\d+)\.(\d+)\.(\d+)\s(\d+):(\d+):(\d+)/
),
deathsMatch: text.match(/todayDeath\s?=\s?'(\d+)'/),
infectedMatch: text.match(/todaySumInfected\s?=\s?'(\d+)'/),
recoveredMatch: text.match(/todayHealth\s?=\s?'(\d+)'/)
}

const errors = Object.entries(matches).filter(([key, value]) => !value)

if (errors.length > 0) {
throw new Error(
`No match for: ${errors.map(([key]) => key).join(', ')}`
)
}

const {
activeMatch,
dateMatch,
deathsMatch,
infectedMatch,
recoveredMatch
} = matches

return [
{
areacode: 'rd',
active: Number(activeMatch[1]),
date: new Date(
`${dateMatch[3]}-${dateMatch[2]}-${dateMatch[1]}T${dateMatch[4]}:${dateMatch[5]}:${dateMatch[6]}.000`
).toISOString(),
deaths: Number(deathsMatch[1]),
infected: Number(infectedMatch[1]),
quarantined: null,
recovered: Number(recoveredMatch[1])
}
]
})
9 changes: 5 additions & 4 deletions packages/frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ import './styles.css'

const locations = {
fl: 'Flensburg',
'ks-s': 'Kassel',
'ks-lk': 'Landkreis Kassel',
'ks-s': 'Kassel',
l: 'Leipzig',
lg: 'Landkreis Lüneburg',
od: 'Kreis Stormarn',
plö: 'Kreis Plön',
rd: 'Kreis Rendsburg-Eckernförde',
row: 'Landkreis Rotenburg',
l: 'Leipzig',
rz: 'Kreis Herzogtum Lauenburg',
plö: 'Kreis Plön',
sl: 'Kreis Schleswig-Flensburg',
od: 'Kreis Stormarn'
}

const db = new PouchDB('coronastats')
Expand Down
54 changes: 31 additions & 23 deletions packages/frontend/src/data/areacodes.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@
"sourceUri": "https://www.flensburg.de/Aktuelles/Corona-Portal/Aktuelle-Lagemeldungen/Aktuelles-Infektionsgeschehen/",
"state": "sh"
},
"rz": {
"population": 198019,
"populationSourceLabel": "Statistikamt Nord",
"populationSourceUri": "https://www.statistik-nord.de/",
"sourceLabel": "kreis-rz.de",
"sourceUri": "https://www.kreis-rz.de/Corona",
"state": "sh"
"ks-lk": {
"population": 236764,
"populationSourceLabel": "Hessisches Statistisches Landesamt",
"populationSourceUri": "https://statistik.hessen.de/zahlen-fakten/bevoelkerung-gebiet-haushalte-familien/bevoelkerung/tabellen/#Bevoelkerungsveraenderung",
"sourceLabel": "kassel.de",
"sourceUri": "https://www.kassel.de/aktuelles/aktuelle-meldungen/coronavirus.php",
"state": "he"
},
"ks-s": {
"population": 202137,
"populationSourceLabel": "Hessisches Statistisches Landesamt",
"populationSourceUri": "https://statistik.hessen.de/zahlen-fakten/bevoelkerung-gebiet-haushalte-familien/bevoelkerung/tabellen/#Bevoelkerungsveraenderung",
"sourceLabel": "kassel.de",
"sourceUri": "https://www.kassel.de/aktuelles/aktuelle-meldungen/coronavirus.php",
"state": "he"
},
"l": {
"population": 593145,
Expand All @@ -31,22 +39,6 @@
"sourceUri": "https://corona.landkreis-lueneburg.de/aktuelle-situation/",
"state": "ni"
},
"ks-lk": {
"population": 236764,
"populationSourceLabel": "Hessisches Statistisches Landesamt",
"populationSourceUri": "https://statistik.hessen.de/zahlen-fakten/bevoelkerung-gebiet-haushalte-familien/bevoelkerung/tabellen/#Bevoelkerungsveraenderung",
"sourceLabel": "kassel.de",
"sourceUri": "https://www.kassel.de/aktuelles/aktuelle-meldungen/coronavirus.php",
"state": "he"
},
"ks-s": {
"population": 202137,
"populationSourceLabel": "Hessisches Statistisches Landesamt",
"populationSourceUri": "https://statistik.hessen.de/zahlen-fakten/bevoelkerung-gebiet-haushalte-familien/bevoelkerung/tabellen/#Bevoelkerungsveraenderung",
"sourceLabel": "kassel.de",
"sourceUri": "https://www.kassel.de/aktuelles/aktuelle-meldungen/coronavirus.php",
"state": "he"
},
"od": {
"population": 244156,
"populationSourceLabel": "Statistikamt Nord",
Expand All @@ -71,6 +63,22 @@
"sourceUri": "https://www.lk-row.de/portal/seiten/aktuelle-zahlen-corona--900000752-23700.html",
"state": "ni"
},
"rd": {
"population": 274765,
"populationSourceLabel": "Statistikamt Nord",
"populationSourceUri": "https://www.statistik-nord.de/",
"sourceLabel": "covid19dashboardrdeck.aco",
"sourceUri": "https://covid19dashboardrdeck.aco",
"state": "sh"
},
"rz": {
"population": 198019,
"populationSourceLabel": "Statistikamt Nord",
"populationSourceUri": "https://www.statistik-nord.de/",
"sourceLabel": "kreis-rz.de",
"sourceUri": "https://www.kreis-rz.de/Corona",
"state": "sh"
},
"sl": {
"population": 201156,
"populationSourceLabel": "Statistikamt Nord",
Expand Down

0 comments on commit 0bba3a5

Please sign in to comment.