history cache
This commit is contained in:
26
src/market/history/EsiMarketOrderHistory.ts
Normal file
26
src/market/history/EsiMarketOrderHistory.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { esiAxiosInstance } from "@/service";
|
||||
|
||||
|
||||
export type EsiMarketOrderHistory = {
|
||||
average: number;
|
||||
date: string;
|
||||
highest: number;
|
||||
lowest: number;
|
||||
order_count: number;
|
||||
volume: number;
|
||||
}
|
||||
|
||||
// TODO use pinia store
|
||||
const historyCache: { [key: number]: { [key: number]: EsiMarketOrderHistory[] } } = {};
|
||||
|
||||
export const getHistory = async (regionId: number, tyeId: number): Promise<EsiMarketOrderHistory[]> => {
|
||||
if (historyCache[regionId]?.[tyeId]) {
|
||||
return historyCache[regionId][tyeId];
|
||||
}
|
||||
|
||||
const value = (await esiAxiosInstance.get(`/markets/${regionId}/history/`, { params: { type_id: tyeId } })).data;
|
||||
|
||||
historyCache[regionId] = historyCache[regionId] ?? {};
|
||||
historyCache[regionId][tyeId] = value;
|
||||
return value;
|
||||
}
|
||||
Reference in New Issue
Block a user