feat(#17): Add an appraisal compare-by-location page

This commit is contained in:
Sirttas
2026-07-09 19:06:53 +02:00
parent c4803ef650
commit 81250953eb
17 changed files with 361 additions and 21 deletions
+6 -6
View File
@@ -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;