market types from mammon

This commit is contained in:
Sirttas
2026-06-13 16:30:31 +02:00
parent 3a35d2181d
commit 16078cc62b
5 changed files with 184 additions and 55 deletions
+11 -11
View File
@@ -1,15 +1,15 @@
import { defineStore } from 'pinia';
import { RegionalMarketCache } from '../RegionalMarketCache';
import { jitaId } from '../market';
import { MarketType } from "../type";
import { MarketTypePrice } from './MarketTypePrice';
import { getMammonPrices } from './mammon';
import {defineStore} from 'pinia';
import {RegionalMarketCache} from '../RegionalMarketCache';
import {jitaId} from '../market';
import {MarketType} from "../type";
import {MarketTypePrice} from './MarketTypePrice';
import {getMammonPrices} from './mammon';
const cacheDuration = 1000 * 60 * 5; // 5 minutes
const batchSize = 100;
const CACHE_DURATION = 1000 * 60 * 5; // 5 minutes
const BATCH_SIZE = 100;
export const useApraisalStore = defineStore('appraisal', () => {
const cache: RegionalMarketCache<MarketTypePrice> = new RegionalMarketCache(cacheDuration);
const cache: RegionalMarketCache<MarketTypePrice> = new RegionalMarketCache(CACHE_DURATION);
const getPricesUncached = getMammonPrices;
@@ -32,8 +32,8 @@ export const useApraisalStore = defineStore('appraisal', () => {
if (uncached.length > 0) {
const batches: Promise<MarketTypePrice[]>[] = [];
for (let i = 0; i < uncached.length; i += batchSize) {
batches.push(getPricesUncached(uncached.slice(i, i + batchSize)));
for (let i = 0; i < uncached.length; i += BATCH_SIZE) {
batches.push(getPricesUncached(uncached.slice(i, i + BATCH_SIZE)));
}
const prices = (await Promise.all(batches)).flat();