diff --git a/README.md b/README.md index 04a6813..191ae37 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/packages/crawler/lib/index.js b/packages/crawler/lib/index.js index de4c51f..bdb10fb 100644 --- a/packages/crawler/lib/index.js +++ b/packages/crawler/lib/index.js @@ -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')() diff --git a/packages/crawler/lib/rd.js b/packages/crawler/lib/rd.js new file mode 100644 index 0000000..813583a --- /dev/null +++ b/packages/crawler/lib/rd.js @@ -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]) + } + ] + }) diff --git a/packages/frontend/src/App.js b/packages/frontend/src/App.js index f529dd4..f0239cf 100644 --- a/packages/frontend/src/App.js +++ b/packages/frontend/src/App.js @@ -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') diff --git a/packages/frontend/src/data/areacodes.json b/packages/frontend/src/data/areacodes.json index 5f0b802..f3d63a0 100644 --- a/packages/frontend/src/data/areacodes.json +++ b/packages/frontend/src/data/areacodes.json @@ -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, @@ -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", @@ -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",