extract evepraisal from apraisal
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { evepraisalAxiosInstance } from '@/service';
|
||||
import { MarketType } from "../type";
|
||||
import { MarketTypePrice, PriceGetter } from './MarketTypePrice';
|
||||
|
||||
const batchSize = 100;
|
||||
|
||||
export const getEvepraisalPrices: PriceGetter = async (types: MarketType[]): Promise<MarketTypePrice[]> => {
|
||||
const batches = [];
|
||||
|
||||
for (let i = 0; i < types.length; i += batchSize) {
|
||||
batches.push(evepraisalAxiosInstance.post(`/appraisal.json?market=jita&persist=no&raw_textarea=${types.slice(i, i + batchSize).map(t => t.name).join("%0A")}`));
|
||||
}
|
||||
return (await Promise.all(batches))
|
||||
.flatMap(b => b.data.appraisal.items)
|
||||
.map((item: any) => ({
|
||||
type: types.find(t => t.name === item.typeName) as MarketType,
|
||||
buy: item.prices.buy.max,
|
||||
sell: item.prices.sell.min,
|
||||
orderCount: item.prices.all.order_count
|
||||
}));
|
||||
};
|
||||
Reference in New Issue
Block a user