feat(#17): Add an appraisal compare-by-location page
This commit is contained in:
@@ -13,14 +13,14 @@ export const useAppraisalStore = defineStore('appraisal', () => {
|
||||
|
||||
const getPricesUncached = getMammonPrices;
|
||||
|
||||
const getPrice = async (type: MarketType, regionId?: number): Promise<MarketTypePrice> => (await getPrices([type], regionId))[0];
|
||||
const getPrices = async (types: MarketType[], regionId?: number): Promise<MarketTypePrice[]> => {
|
||||
const getPrice = async (type: MarketType, locationId?: number): Promise<MarketTypePrice> => (await getPrices([type], locationId))[0];
|
||||
const getPrices = async (types: MarketType[], locationId?: number): Promise<MarketTypePrice[]> => {
|
||||
const cached: MarketTypePrice[] = [];
|
||||
const uncached: MarketType[] = [];
|
||||
const rId = regionId ?? jitaId;
|
||||
const lId = locationId ?? jitaId;
|
||||
|
||||
types.forEach(t => {
|
||||
const cachedPrice = cache.get(rId, t.id);
|
||||
const cachedPrice = cache.get(lId, t.id);
|
||||
|
||||
if (cachedPrice) {
|
||||
cached.push(cachedPrice);
|
||||
@@ -33,12 +33,12 @@ export const useAppraisalStore = defineStore('appraisal', () => {
|
||||
const batches: Promise<MarketTypePrice[]>[] = [];
|
||||
|
||||
for (let i = 0; i < uncached.length; i += BATCH_SIZE) {
|
||||
batches.push(getPricesUncached(uncached.slice(i, i + BATCH_SIZE)));
|
||||
batches.push(getPricesUncached(uncached.slice(i, i + BATCH_SIZE), lId));
|
||||
}
|
||||
|
||||
const prices = (await Promise.all(batches)).flat();
|
||||
|
||||
prices.forEach(p => cache.set(rId, p.type.id, p));
|
||||
prices.forEach(p => cache.set(lId, p.type.id, p));
|
||||
return [ ...cached, ...prices ];
|
||||
}
|
||||
return cached;
|
||||
|
||||
Reference in New Issue
Block a user