Skip to content

Commit

Permalink
🐛 Await for legacy result
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Oct 6, 2020
1 parent 43b0201 commit c3d3d9a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
11 changes: 3 additions & 8 deletions src/api/google-fit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,11 @@ export default class GoogleFit implements Integration {
}

async legacy(start: string) {
const CONCURRENCY = 1;
const startDate = dayjs(start);
let count = 0;
const pool = new PromisePool(async () => {
for await (const count of [...Array(dayjs().diff(startDate, "day")).keys()]) {
const date = dayjs(startDate).add(count, "day");
if (dayjs().diff(date, "day") === 0) return null;
count++;
return updateGoogleFitDailyData(date.toDate());
}, CONCURRENCY);
await pool.start();
await updateGoogleFitDailyData(date.toDate());
}
console.log("Done!");
}

Expand Down
3 changes: 1 addition & 2 deletions src/api/last-fm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,9 @@ export default class LastDotFm implements Integration {
const startDate = dayjs(start);
for await (const count of [...Array(dayjs().diff(startDate, "day")).keys()]) {
const date = dayjs(startDate).add(count, "day");
return getLastFmTracks(date.toDate());
await getLastFmTracks(date.toDate());
}
console.log("Done!");
console.log("Done!");
}
async summary() {}
}
2 changes: 1 addition & 1 deletion src/api/oura-ring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default class OuraRing implements Integration {
const startDate = dayjs(start);
for await (const count of [...Array(dayjs().diff(startDate, "day")).keys()]) {
const date = dayjs(startDate).add(count, "day");
return updateOuraDailyData(date.toDate());
await updateOuraDailyData(date.toDate());
}
console.log("Done!");
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/wakatime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class Wakatime implements Integration {
const startDate = dayjs(start);
for await (const count of [...Array(dayjs().diff(startDate, "day")).keys()]) {
const date = dayjs(startDate).add(count, "day");
return updateWakatimeDailyData(date.toDate());
await updateWakatimeDailyData(date.toDate());
}
console.log("Done!");
}
Expand Down

0 comments on commit c3d3d9a

Please sign in to comment.