cleanup and fix
This commit is contained in:
@@ -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<MarketTypePrice> = new RegionalMarketCache(cacheDuration);
|
||||
@@ -29,7 +30,13 @@ export const useApraisalStore = defineStore('appraisal', () => {
|
||||
});
|
||||
|
||||
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));
|
||||
return [ ...cached, ...prices ];
|
||||
|
||||
Reference in New Issue
Block a user