Skip to content

Commit 8d36e0f

Browse files
authored
Merge pull request #1150 from cmu-delphi/sgratzl/quidel_counties
Fetch individual regions separately
2 parents 5959e3c + 0997837 commit 8d36e0f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/stores/DataFetcher.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,17 @@ export class DataFetcher {
190190
return this.cache.get(key) as Promise<RegionEpiDataRow[]>;
191191
}
192192

193-
const r = fetchTriple(lSensor, regions, timeFrame, { asOf: this.asOf }).then(addNameInfos);
193+
let r: Promise<(EpiDataRow & Region)[]>;
194+
195+
if (typeof regions === 'string') {
196+
r = fetchTriple(lSensor, regions, timeFrame, { asOf: this.asOf }).then(addNameInfos);
197+
} else {
198+
// fetch individually for better db performance
199+
r = Promise.all(regions.map((region) => this.fetch1Sensor1RegionNDates(lSensor, region, timeFrame))).then(
200+
(rows) => rows.flat(),
201+
);
202+
}
203+
194204
// no missing
195205
this.cache.set(key, r);
196206
return r;

0 commit comments

Comments
 (0)