Skip to content

Commit

Permalink
fix: added workaround to (hopefully) fix cursor error on Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
juzraai committed Dec 29, 2021
1 parent f0c455e commit e06e6f5
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions services/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,19 @@ export default {
const r = {};
const ids = [];
console.time('[TLL] Last prices/opponent queried in');
await this.table(role, result)
.orderBy('opponentId').uniqueKeys(opponentIds => {
ids.push(...opponentIds);
});
await Promise.all(ids.map(async id => {
const attacks = await this.table(role, result)
.where('opponentId').equals(id)
.sortBy('timestamp');
r[id] = attacks.length ? attacks[attacks.length - 1].price : 0;
}));
const c = await this.countAttacks(role, result);
if (c > 0) {
await this.table(role, result)
.orderBy('opponentId').uniqueKeys(opponentIds => {
ids.push(...opponentIds);
});
await Promise.all(ids.map(async id => {
const attacks = await this.table(role, result)
.where('opponentId').equals(id)
.sortBy('timestamp');
r[id] = attacks.length ? attacks[attacks.length - 1].price : 0;
}));
}
console.timeEnd('[TLL] Last prices/opponent queried in');
return r;
},
Expand Down

0 comments on commit e06e6f5

Please sign in to comment.