<commit_before>// Simple way to grab all the matches of a player. There might be a better way, but I can't remember
// if totalGames is reliable, which is why I go for a 404 check on top of the index check.

// Destructures match object.
const matchToGameId = ({ gameId }) => gameId

// getFN is required because of this file structure where `kayn` isn't included.
// mutationsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
const getAllMatchIDs = async (matchlistDTO, accountID, getFn) => {
    const { totalGames } = matchlistDTO
    console.log(`Total number of games to process: ${totalGames}`)

    // Batch up calls together.
    const apiCalls = []
    if (totalGames > 100) {
        for (let beginIndex = 100; beginIndex < totalGames; beginIndex += 100) {
            const endIndex = beginIndex + 100
            const indexQuery = { beginIndex, endIndex }
            apiCalls.push(getFn(accountID, indexQuery))
        }
    }

    const restOfMatchIDs = (await Promise.all(apiCalls))
        .map(({ matches }) => matches)
        .reduce((total, curr) => total.concat(curr), [])
        .map(matchToGameId)

    return [...matchlistDTO.matches.map(matchToGameId), ...restOfMatchIDs]
}

const main = async kayn => {
    const getRankedMatchesForSummoner = async (accountID, indexQuery) =>
        kayn.Matchlist.by
            .accountID(accountID)
            .region('na')
            .query({ queue: 420, season: 9 })
            .query(indexQuery || {})

    const { accountId: accountID } = await kayn.Summoner.by.name('Contractz')

    // First DTO to get the total number of games.
    const firstMatchlistDTO = await getRankedMatchesForSummoner(accountID)
    const matchIDs = await getAllMatchIDs(
        firstMatchlistDTO,
        accountID,
        getRankedMatchesForSummoner,
    )

    // Now we have all the match ids!
    // Can batch process them now.
    const matches = await Promise.all(matchIDs.map(kayn.Match.get))<commit_msg>refactor (Examples): Clean up match ids example for less temporary variables<commit_after>// Simple way to grab all the matches of a player.

// Destructures matchlist object to matches.
const matchlistToMatches = ({ matches }) => matches
// Destructures match object.
const matchToGameId = ({ gameId }) => gameId

// getFN is required because of this file structure where `kayn` isn't included.
// mutationsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
const getAllMatchIDs = async (matchlistDTO, accountID, getFn) => {
    const { totalGames } = matchlistDTO
    console.log(`Total number of games to process: ${totalGames}`)

    // Batch up calls together.
    const apiCalls = []
    if (totalGames > 100) {
        for (let beginIndex = 100; beginIndex < totalGames; beginIndex += 100) {
            const endIndex = beginIndex + 100
            const indexQuery = { beginIndex, endIndex }
            apiCalls.push(getFn(accountID, indexQuery))
        }
    }

    return [matchlistDTO]
        .concat(await Promise.all(apiCalls))
        .map(matchlistToMatches)
        .reduce((total, curr) => total.concat(curr), [])
        .map(matchToGameId)
}

const main = async kayn => {
    const getRankedMatchesForSummoner = async (accountID, indexQuery) =>
        kayn.Matchlist.by
            .accountID(accountID)
            .region('na')
            .query({ queue: 420, season: 9 })
            .query(indexQuery || {})

    const { accountId: accountID } = await kayn.Summoner.by.name('Contractz')

    // First DTO to get the total number of games.
    const firstMatchlistDTO = await getRankedMatchesForSummoner(accountID)
    const matchIDs = await getAllMatchIDs(
        firstMatchlistDTO,
        accountID,
        getRankedMatchesForSummoner,
    )

    // Now we have all the match ids!
    // Can batch process them now.
    const matches = await Promise.all(matchIDs.map(kayn.Match.get))
{'fraction_non_alphanumeric': 0.10099974365547296, 'fraction_numerical': 0.008972058446552167, 'mean_word_length': 2.8519249753208293, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2762160', 'n_tokens_mistral': 1218, 'n_tokens_neox': 1169, 'n_words': 336}