diff --git a/src/market/appraisal/appraisal.ts b/src/market/appraisal/appraisal.ts index 048d81a..18ab28f 100644 --- a/src/market/appraisal/appraisal.ts +++ b/src/market/appraisal/appraisal.ts @@ -6,6 +6,7 @@ import { MarketTypePrice } from './MarketTypePrice'; import { getMammonPrices } from './mammon'; const cacheDuration = 1000 * 60 * 5; // 5 minutes +const batchSize = 100; export const useApraisalStore = defineStore('appraisal', () => { const cache: RegionalMarketCache = new RegionalMarketCache(cacheDuration); @@ -29,7 +30,13 @@ export const useApraisalStore = defineStore('appraisal', () => { }); if (uncached.length > 0) { - const prices = await getPricesUncached(uncached); + const batches: Promise[] = []; + + for (let i = 0; i < uncached.length; i += batchSize) { + batches.push(getPricesUncached(uncached.slice(i, i + batchSize))); + } + + const prices = (await Promise.all(batches)).flat(); prices.forEach(p => cache.set(rId, p.type.id, p)); return [ ...cached, ...prices ];