2025-10-12 15:05:58 +00:00
|
|
|
import { patientFetch } from "../blitzkit/patientFetch";
|
|
|
|
|
import { withCORSProxy } from "../blitzkit/withCORSProxy";
|
2025-10-13 23:20:26 -05:00
|
|
|
import type { RatingNeighbors } from "./rating";
|
|
|
|
|
import type { Region } from "./regions";
|
2025-10-12 15:05:58 +00:00
|
|
|
import { regionToRegionSubdomain } from "./regionToRegionSubdomain";
|
2023-11-07 20:47:20 -06:00
|
|
|
|
2024-03-20 17:33:21 -05:00
|
|
|
export async function getRatingNeighbors(
|
2023-11-07 20:47:20 -06:00
|
|
|
region: Region,
|
|
|
|
|
id: number,
|
2023-11-11 21:37:59 -06:00
|
|
|
count: number,
|
2025-10-12 15:05:58 +00:00
|
|
|
usePatientFetcher = false
|
2023-11-07 20:47:20 -06:00
|
|
|
) {
|
2023-11-16 11:13:51 -06:00
|
|
|
const fetcher = (url: string) =>
|
|
|
|
|
usePatientFetcher
|
2025-10-12 15:05:58 +00:00
|
|
|
? patientFetch(url, undefined, { cache: "no-store" })
|
|
|
|
|
: fetch(url, { cache: "no-store" });
|
2023-11-07 20:47:20 -06:00
|
|
|
const response = await fetcher(
|
2023-11-13 21:52:21 -06:00
|
|
|
withCORSProxy(
|
|
|
|
|
`https://${regionToRegionSubdomain(
|
2025-10-12 15:05:58 +00:00
|
|
|
region
|
|
|
|
|
)}.wotblitz.com/en/api/rating-leaderboards/user/${id}/?neighbors=${count}`
|
|
|
|
|
)
|
2023-11-07 20:47:20 -06:00
|
|
|
);
|
2024-03-20 17:33:21 -05:00
|
|
|
const json = (await response.json()) as RatingNeighbors;
|
2023-11-07 20:47:20 -06:00
|
|
|
|
|
|
|
|
return json;
|
|
|
|
|
}
|