Skip to content

Commit 476af42

Browse files
committed
added wip function
1 parent 1bee564 commit 476af42

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/App.svelte

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@
3636
let first_loaded = true;
3737
3838
function callAPI(id, signal, level, date, region) {
39+
console.log(
40+
ENDPOINT +
41+
'&data_source=' +
42+
id +
43+
'&signal=' +
44+
signal +
45+
'&geo_type=' +
46+
level +
47+
'&time_values=' +
48+
date +
49+
'&geo_value=' +
50+
region,
51+
);
3952
return fetch(
4053
ENDPOINT +
4154
'&data_source=' +
@@ -68,6 +81,12 @@
6881
return new_epidata;
6982
}
7083
84+
function check_wip(signal_name, other_signal) {
85+
if (signal_name.match(/wip/)) {
86+
return 'wip_' + other_signal.replace('incidence', 'incid');
87+
}
88+
return other_signal;
89+
}
7190
// We cache API calls for all regions at a given time and update currentData.
7291
function updateRegionSliceCache(sensor, level, date, reason = 'unspecified') {
7392
let sEntry = $sensorMap.get(sensor);
@@ -86,13 +105,13 @@
86105
if (sEntry.signal.match(death_regex)) {
87106
// deaths_incidence_prop
88107
if (sEntry.signal === 'deaths_7dav_incidence_prop') {
89-
callAPI(sEntry.id, 'deaths_incidence_prop', level, date, '*').then(d1 => {
108+
callAPI(sEntry.id, check_wip(sEntry.signal, 'deaths_incidence_prop'), level, date, '*').then(d1 => {
90109
var extended = extend(d, d1);
91110
currentData.set(extended);
92111
regionSliceCache.update(m => m.set(sensor + level + date, extended));
93112
});
94113
} else {
95-
callAPI(sEntry.id, 'deaths_incidence_num', level, date, '*').then(d1 => {
114+
callAPI(sEntry.id, check_wip(sEntry.signal, 'deaths_incidence_num'), level, date, '*').then(d1 => {
96115
var extended = extend(d, d1);
97116
currentData.set(extended);
98117
regionSliceCache.update(m => m.set(sensor + level + date, extended));
@@ -103,13 +122,13 @@
103122
else if (sEntry.signal.match(cases_regex)) {
104123
// confirmed_incidence_prop
105124
if (sEntry.signal === 'confirmed_7dav_incidence_prop') {
106-
callAPI(sEntry.id, 'confirmed_incidence_prop', level, date, '*').then(d1 => {
125+
callAPI(sEntry.id, check_wip(sEntry.signal, 'confirmed_incidence_prop'), level, date, '*').then(d1 => {
107126
var extended = extend(d, d1);
108127
currentData.set(extended);
109128
regionSliceCache.update(m => m.set(sensor + level + date, extended));
110129
});
111130
} else {
112-
callAPI(sEntry.id, 'confirmed_incidence_num', level, date, '*').then(d1 => {
131+
callAPI(sEntry.id, check_wip(sEntry.signal, 'confirmed_incidence_num'), level, date, '*').then(d1 => {
113132
var extended = extend(d, d1);
114133
currentData.set(extended);
115134
regionSliceCache.update(m => m.set(sensor + level + date, extended));

0 commit comments

Comments
 (0)