fix: no cross-bot imports

This commit is contained in:
TrèsAbhi committed 2024-09-07 23:00:56 -05:00
1 parent 6c0b46725d
commit 7c6f381bbe
58 files changed
+233 -252

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
export interface Clan {
members_count: number;
created_at: number;
clan_id: number;
tag: string;
name: string;
}
export type ClanList = Clan[];
+2 -1
View File
@@ -1,9 +1,10 @@
export * from './clans';
export * from './constants';
export * from './equipmentPrice';
export * from './idToRegion';
export * from './leagues';
export * from './nations';
export * from './permanentSkills';
export * from './rating';
export * from './regions';
export * from './resolveNearPenetration';
export * from './searchClansAcrossRegions';
-7
View File
@@ -1,7 +0,0 @@
export const LEAGUES = [
{ name: 'diamond', minScore: 5000, index: 0 },
{ name: 'platinum', minScore: 4000, index: 1 },
{ name: 'gold', minScore: 3000, index: 2 },
{ name: 'silver', minScore: 2000, index: 3 },
{ name: 'bronze', minScore: -Infinity, index: 4 },
];
+78 -1
View File
@@ -1,2 +1,79 @@
export const FIRST_MINIMAL_ARCHIVED_RATING_SEASON = 49;
import { RatingPlayer } from '../statistics';
export const LEAGUES = [
{ name: 'diamond', minScore: 5000, index: 0 },
{ name: 'platinum', minScore: 4000, index: 1 },
{ name: 'gold', minScore: 3000, index: 2 },
{ name: 'silver', minScore: 2000, index: 3 },
{ name: 'bronze', minScore: -Infinity, index: 4 },
];
export type RatingInfo =
| {
detail: undefined;
title: string;
icon: string | null;
start_at: string;
finish_at: string;
current_season: number;
updated_at: string;
count: number;
rewards: RatingReward[];
leagues: RatingLeague[];
}
| { detail: { error: string } };
export interface RatingNeighbors {
neighbors: RatingPlayer[];
}
export const FIRST_COMPREHENSIVE1_ARCHIVED_RATING_SEASON = 53;
export const FIRST_MINIMAL_ARCHIVED_RATING_SEASON = 49;
export interface LeagueTop {
result: RatingPlayer[];
}
export interface RatingLeague {
title: string;
small_icon: string;
big_icon: string;
background: string;
index: number;
percentile: number;
}
export type RatingReward = {
from_position: number;
to_position: number;
count: number;
} & (
| {
type: 'vehicle';
vehicle: {
id: number;
name: string;
nation: string;
subnation: string;
use_subnation_flag: boolean;
type_slug: string;
level: number;
roman_level: string;
user_string: string;
image_url: string;
preview_image_url: string;
is_premium: boolean;
is_collectible: boolean;
};
}
| {
type: 'stuff';
stuff: {
name: string;
count: number;
title: string;
image_url: string;
type: string;
sizes: {};
};
}
);
@@ -0,0 +1,54 @@
import { Region } from '@blitzkit/core';
import fetchBlitz from '../../../website/src/core/blitz/fetchBlitz';
import { ClanList } from './clans';
export default async function searchClansAcrossRegions(
search: string,
limit = 25,
) {
const trimmed = search.trim();
if (trimmed.length < 3 && trimmed.length > 100) return [];
const normalizedLimit = Math.floor(limit / 3);
// TODO: remove splice once wargaming fixes the functionality of the limit felid
return (
await Promise.all([
fetchBlitz<ClanList>('com', 'clans/list', {
search,
limit: normalizedLimit,
}).then((value) =>
value
.map((account) => ({
...account,
region: 'com' as Region,
}))
.splice(0, normalizedLimit),
),
fetchBlitz<ClanList>('eu', 'clans/list', {
search,
limit: normalizedLimit,
}).then((value) =>
value
.map((account) => ({
...account,
region: 'eu' as Region,
}))
.splice(0, normalizedLimit),
),
fetchBlitz<ClanList>('asia', 'clans/list', {
search,
limit: normalizedLimit,
}).then((value) =>
value
.map((account) => ({
...account,
region: 'asia' as Region,
}))
.splice(0, normalizedLimit),
),
])
)
.filter(Boolean)
.flat();
}