|
36 | 36 | let first_loaded = true;
|
37 | 37 |
|
38 | 38 | 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 | + ); |
39 | 52 | return fetch(
|
40 | 53 | ENDPOINT +
|
41 | 54 | '&data_source=' +
|
|
68 | 81 | return new_epidata;
|
69 | 82 | }
|
70 | 83 |
|
| 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 | + } |
71 | 90 | // We cache API calls for all regions at a given time and update currentData.
|
72 | 91 | function updateRegionSliceCache(sensor, level, date, reason = 'unspecified') {
|
73 | 92 | let sEntry = $sensorMap.get(sensor);
|
|
86 | 105 | if (sEntry.signal.match(death_regex)) {
|
87 | 106 | // deaths_incidence_prop
|
88 | 107 | 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 => { |
90 | 109 | var extended = extend(d, d1);
|
91 | 110 | currentData.set(extended);
|
92 | 111 | regionSliceCache.update(m => m.set(sensor + level + date, extended));
|
93 | 112 | });
|
94 | 113 | } 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 => { |
96 | 115 | var extended = extend(d, d1);
|
97 | 116 | currentData.set(extended);
|
98 | 117 | regionSliceCache.update(m => m.set(sensor + level + date, extended));
|
|
103 | 122 | else if (sEntry.signal.match(cases_regex)) {
|
104 | 123 | // confirmed_incidence_prop
|
105 | 124 | 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 => { |
107 | 126 | var extended = extend(d, d1);
|
108 | 127 | currentData.set(extended);
|
109 | 128 | regionSliceCache.update(m => m.set(sensor + level + date, extended));
|
110 | 129 | });
|
111 | 130 | } 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 => { |
113 | 132 | var extended = extend(d, d1);
|
114 | 133 | currentData.set(extended);
|
115 | 134 | regionSliceCache.update(m => m.set(sensor + level + date, extended));
|
|
0 commit comments