-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-rankings.ts
55 lines (49 loc) · 1.14 KB
/
update-rankings.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* eslint-disable no-console */
/* eslint-disable no-await-in-loop */
// eslint-disable-next-line import/no-extraneous-dependencies
import { HLTV } from 'hltv';
import fs from 'node:fs';
const wait = async (ms: number) => {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
};
const rankData = [];
const regions = [
'United States',
'Brazil',
'Czech Republic',
'Denmark',
'Finland',
'Germany',
'Kazakhstan',
'Latvia',
'Poland',
'Portuga',
'Russia',
'Sweden',
'Ukraine',
'United Kingdom',
'China',
'India',
'Mongolia',
'Australia',
];
console.log('Getting global ranking');
rankData.push(await HLTV.getTeamRanking());
for (const region of regions) {
await wait(1000);
console.log('Getting region ranking:', region);
rankData.push(await HLTV.getTeamRanking({ country: region }));
}
const pointMappings: Record<string, number> = {};
rankData.forEach((ranking) => {
ranking.forEach((team) => {
pointMappings[team.team.name] = team.points;
});
});
fs.writeFileSync(
'src/hltv-team-points.ts',
`export default ${JSON.stringify(pointMappings, null, 2)} as Record<string, number>;`,
'utf-8'
);