<commit_before>import { IMessage } from '../interface';
import { httpRequest } from '../lib/helpers';

export type ExtraLifeType = 'all' | 'goal' | 'total';

interface IAPIData {
    displayName: string;
    fundraisingGoal: number;
    eventName: string;
    links: {
        donate: string;
    };
    sumDonations: number;
    teamName: string;
    sumPledges: number;
    numDonations: number;
}

export async function extralife(_message: IMessage, _settings: any, request: typeof fetch, id: string, type: ExtraLifeType = 'all') {
    const req: IAPIData = await httpRequest(request, `https://www.extra-life.org/api/participants/${id}`);
    if (req === undefined || (<any>req).length === 0) {
        return '[API Error]';
    }

    switch (type) {
        case 'goal':
            return parseNum(req.sumDonations);
        case 'total':
            return `${parseNum(req.fundraisingGoal)} (${totalPercentage(req.fundraisingGoal, req.sumDonations)}%)`;
        case 'all':
        default:
            // tslint:disable-next-line: max-line-length
            return `Raised: ${parseNum(req.sumDonations)} Goal: ${parseNum(req.fundraisingGoal)} (${totalPercentage(req.fundraisingGoal, req.sumDonations)}%)`;<commit_msg>fix(extralife): returning the wrong number for total<commit_after>import { IMessage } from '../interface';
import { httpRequest } from '../lib/helpers';

export type ExtraLifeType = 'all' | 'goal' | 'total';

interface IAPIData {
    displayName: string;
    fundraisingGoal: number;
    eventName: string;
    links: {
        donate: string;
    };
    sumDonations: number;
    teamName: string;
    sumPledges: number;
    numDonations: number;
}

export async function extralife(_message: IMessage, _settings: any, request: typeof fetch, id: string, type: ExtraLifeType = 'all') {
    const req: IAPIData = await httpRequest(request, `https://www.extra-life.org/api/participants/${id}`);
    if (req === undefined || (<any>req).length === 0) {
        return '[API Error]';
    }

    switch (type) {
        case 'goal':
            return parseNum(req.sumDonations);
        case 'total':
            return `${parseNum(req.sumDonations)} (${totalPercentage(req.fundraisingGoal, req.sumDonations)}%)`;
        case 'all':
        default:
            // tslint:disable-next-line: max-line-length
            return `Raised: ${parseNum(req.sumDonations)} Goal: ${parseNum(req.fundraisingGoal)} (${totalPercentage(req.fundraisingGoal, req.sumDonations)}%)`;
{'fraction_non_alphanumeric': 0.147508038585209, 'fraction_numerical': 0.0008038585209003215, 'mean_word_length': 3.269296740994854, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '6926384', 'n_tokens_mistral': 781, 'n_tokens_neox': 773, 'n_words': 177}