MCPcopy
hub / github.com/SYJun404/frank / queryMatchHistory

Function queryMatchHistory

src/lcu/aboutMatch.ts:37–62  ·  view source on GitHub ↗
(puuid: string, begIndex: number, endIndex: number)

Source from the content-addressed store, hash-verified

35
36// 主函数:查询历史比赛数据
37export 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

Callers 4

BaseMatchClass · 0.90
QueryMatchClass · 0.90
queryPlatformIdFunction · 0.90
QueryMatchClass · 0.90

Calls 2

splitRequestsFunction · 0.85
fetchMatchHistoryFunction · 0.85

Tested by

no test coverage detected