(puuid: string, begIndex: number, endIndex: number)
| 13 | |
| 14 | // 辅助函数:拆分请求区间 |
| 15 | const splitRequests = async (puuid: string, begIndex: number, endIndex: number): Promise<Games[]> => { |
| 16 | const step = 10; // 每段的范围为 10 |
| 17 | let allGames: Games[] = []; |
| 18 | let currentBegIndex = begIndex; |
| 19 | |
| 20 | // 循环拆分请求 |
| 21 | while (currentBegIndex < endIndex) { |
| 22 | const currentEndIndex = Math.min(currentBegIndex + step - 1, endIndex); |
| 23 | const games = await fetchMatchHistory(puuid, currentBegIndex, currentEndIndex); |
| 24 | |
| 25 | if (games.length > 0) { |
| 26 | allGames = allGames.concat(games); |
| 27 | } |
| 28 | |
| 29 | currentBegIndex = currentEndIndex + 1; |
| 30 | await delay(200); |
| 31 | } |
| 32 | |
| 33 | return allGames; |
| 34 | }; |
| 35 | |
| 36 | // 主函数:查询历史比赛数据 |
| 37 | export const queryMatchHistory = async (puuid: string, begIndex: number, endIndex: number): Promise<Games[] | null> => { |
no test coverage detected