cleanup and fix

This commit is contained in:
Sirttas
2026-06-13 14:36:00 +02:00
parent 6d2b5926bb
commit 3a35d2181d
+8 -1
View File
@@ -6,6 +6,7 @@ import { MarketTypePrice } from './MarketTypePrice';
import { getMammonPrices } from './mammon'; import { getMammonPrices } from './mammon';
const cacheDuration = 1000 * 60 * 5; // 5 minutes const cacheDuration = 1000 * 60 * 5; // 5 minutes
const batchSize = 100;
export const useApraisalStore = defineStore('appraisal', () => { export const useApraisalStore = defineStore('appraisal', () => {
const cache: RegionalMarketCache<MarketTypePrice> = new RegionalMarketCache(cacheDuration); const cache: RegionalMarketCache<MarketTypePrice> = new RegionalMarketCache(cacheDuration);
@@ -29,7 +30,13 @@ export const useApraisalStore = defineStore('appraisal', () => {
}); });
if (uncached.length > 0) { if (uncached.length > 0) {
const prices = await getPricesUncached(uncached); const batches: Promise<MarketTypePrice[]>[] = [];
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)); prices.forEach(p => cache.set(rId, p.type.id, p));
return [ ...cached, ...prices ]; return [ ...cached, ...prices ];