feat: cc account tracking 2

This commit is contained in:
TrèsAbhi committed 2024-04-28 19:16:08 -05:00
1 parent d2b18360ed
commit 38fa15ab97
4 files changed
+48 -12

No files matched your search

+3 -1
View File
@@ -60,10 +60,12 @@ async function manageQueue() {
}
}
export type FetchBlitzParams = Record<string, string | number | undefined>;
export default function fetchBlitz<Data extends object>(
region: Region,
path: string,
params: Record<string, string | number | undefined> = {},
params: FetchBlitzParams = {},
) {
return new Promise<Data>((resolve) => {
queue.push({
+8 -2
View File
@@ -1,5 +1,5 @@
import { Region } from '../../constants/regions';
import fetchBlitz from './fetchBlitz';
import fetchBlitz, { FetchBlitzParams } from './fetchBlitz';
import { normalizeIds } from './normalizeIds';
export interface AllStats {
@@ -95,10 +95,16 @@ export async function getAccountInfo<
ReturnType = Ids extends number
? IndividualAccountInfo
: IndividualAccountInfo[],
>(region: Region, ids: Ids, extra: string[] = []) {
>(
region: Region,
ids: Ids,
extra: string[] = [],
params: FetchBlitzParams = {},
) {
const object = await fetchBlitz<AccountInfo>(region, 'account/info', {
account_id: normalizeIds(ids),
extra: extra.length === 0 ? undefined : extra.join(','),
...params,
});
if (typeof ids === 'number') {
+8 -2
View File
@@ -1,10 +1,16 @@
import { Region } from '../../constants/regions';
import { TanksStats } from '../../types/tanksStats';
import fetchBlitz from './fetchBlitz';
import fetchBlitz, { FetchBlitzParams } from './fetchBlitz';
export default async function getTankStats(region: Region, id: number) {
export default async function getTankStats(
region: Region,
id: number,
params?: FetchBlitzParams,
) {
const tankStats = await fetchBlitz<TanksStats>(region, 'tanks/stats', {
account_id: id,
...params,
});
return tankStats[id];