(puuid: string, begIndex: number, endIndex: number)
| 35 | |
| 36 | // 主函数:查询历史比赛数据 |
| 37 | export const queryMatchHistory = async (puuid: string, begIndex: number, endIndex: number): Promise<Games[] | null> => { |
| 38 | try { |
| 39 | let allGames: Games[] = []; |
| 40 | // 如果 begIndex 与 endIndex 的差值大于 15,拆分请求 |
| 41 | if (endIndex - begIndex > 15) { |
| 42 | allGames = await splitRequests(puuid, begIndex, endIndex); |
| 43 | } else { |
| 44 | // 如果差值不大于 15,直接请求整个范围的数据 |
| 45 | allGames = await fetchMatchHistory(puuid, begIndex, endIndex); |
| 46 | } |
| 47 | |
| 48 | // 如果没有游戏数据,则返回空数组 |
| 49 | if (allGames.length === 0) { |
| 50 | return []; |
| 51 | } |
| 52 | |
| 53 | // 判断是否需要反转游戏数据 |
| 54 | if (allGames[0].gameCreation > allGames[allGames.length - 1].gameCreation) { |
| 55 | return allGames; |
| 56 | } |
| 57 | |
| 58 | return allGames.reverse(); |
| 59 | } catch (e) { |
| 60 | return null; |
| 61 | } |
| 62 | }; |
| 63 |
no test coverage detected