<commit_before>import { Action } from '@ngrx/store';

import { Meteo } from '../models/meteo';
import { RaceInfo } from '../models/race-info';
import { Batch, LoadMain, StopUpdate } from '../state/actions/connection';
import {
    AddIntermediate, AddRacer, AddStartList, RegisterResult,
    SetRaceMessage, SetStatus, UpdateMeteo, UpdateRaceInfo
} from '../state/actions/race';

import { nationalities, statusToTimeMap } from './fis-constants';

export function parseMain(data: any): Action[] {
    const actions: Action[] = [];
    const raceInfo: RaceInfo = {
        eventName: data.raceinfo[0],
        raceName: data.raceinfo[1],
        slopeName: data.raceinfo[2],
        discipline: data.raceinfo[3].toUpperCase(),
        gender: data.raceinfo[4].toUpperCase(),
        category: data.raceinfo[5].toUpperCase(),
        place: data.raceinfo[6],
        temperatureUnit: data.raceinfo[7],
        lengthUnit: data.raceinfo[8],
        speedUnit: data.raceinfo[9],
        team: data.raceinfo[13],
        tds: data.raceinfo[14]
    };
    if (raceInfo.temperatureUnit.length === 1) {
        raceInfo.temperatureUnit = '°' + raceInfo.temperatureUnit;
    }
    if (raceInfo.lengthUnit == null) {
        raceInfo.lengthUnit = 'meters';
    }
    if (raceInfo.speedUnit == null) {
        raceInfo.speedUnit = 'kmh';
    }

    const meteo: Meteo = {
        air_temperature: data.meteo[0],
        wind: data.meteo[1],
        weather: data.meteo[2],
        snow_condition: data.meteo[3],
        snow_temperature: data.meteo[4],
        humidity: data.meteo[5]
    };

    actions.push(new UpdateRaceInfo(raceInfo));
    actions.push(new SetRaceMessage(data.message));
    actions.push(new UpdateMeteo(meteo));
    actions.push(new AddIntermediate({key: 0, id: 0, distance: 0, name: 'Start list'}));

    data.racedef.forEach((def, index) => {
        let name = 'Finish';
        if (def[0] === 'inter') {
            name = '';
        }

        if (def[2] && def[2] > 0) {
            name += ' ' + def[2] + ' KM';
            name = name.trim();
        }

        actions.push(new AddIntermediate({key: index + 1, id: def[1], distance: def[2], name: name}));
    });

    for ( let i = 0; i < data.racers.length; i++ ) {<commit_msg>Use lengthUnit in inter names<commit_after>import { Action } from '@ngrx/store';

import { Meteo } from '../models/meteo';
import { RaceInfo } from '../models/race-info';
import { Batch, LoadMain, StopUpdate } from '../state/actions/connection';
import {
    AddIntermediate, AddRacer, AddStartList, RegisterResult,
    SetRaceMessage, SetStatus, UpdateMeteo, UpdateRaceInfo
} from '../state/actions/race';

import { nationalities, statusToTimeMap } from './fis-constants';

export function parseMain(data: any): Action[] {
    const actions: Action[] = [];
    const raceInfo: RaceInfo = {
        eventName: data.raceinfo[0],
        raceName: data.raceinfo[1],
        slopeName: data.raceinfo[2],
        discipline: data.raceinfo[3].toUpperCase(),
        gender: data.raceinfo[4].toUpperCase(),
        category: data.raceinfo[5].toUpperCase(),
        place: data.raceinfo[6],
        temperatureUnit: data.raceinfo[7],
        lengthUnit: data.raceinfo[8],
        speedUnit: data.raceinfo[9],
        team: data.raceinfo[13],
        tds: data.raceinfo[14]
    };
    if (raceInfo.temperatureUnit.length === 1) {
        raceInfo.temperatureUnit = '°' + raceInfo.temperatureUnit;
    }
    if (raceInfo.lengthUnit == null) {
        raceInfo.lengthUnit = 'meters';
    }
    if (raceInfo.speedUnit == null) {
        raceInfo.speedUnit = 'kmh';
    }

    const meteo: Meteo = {
        air_temperature: data.meteo[0],
        wind: data.meteo[1],
        weather: data.meteo[2],
        snow_condition: data.meteo[3],
        snow_temperature: data.meteo[4],
        humidity: data.meteo[5]
    };

    actions.push(new UpdateRaceInfo(raceInfo));
    actions.push(new SetRaceMessage(data.message));
    actions.push(new UpdateMeteo(meteo));
    actions.push(new AddIntermediate({key: 0, id: 0, distance: 0, name: 'Start list'}));

    data.racedef.forEach((def, index) => {
        let name = 'Finish';
        if (def[0] === 'inter') {
            name = '';
        }

        if (def[2] && def[2] > 0) {
            name += ' ' + def[2] + ' ' + raceInfo.lengthUnit.toUpperCase();
            name = name.trim();
        }

        actions.push(new AddIntermediate({key: index + 1, id: def[1], distance: def[2], name: name}));
    });

    for ( let i = 0; i < data.racers.length; i++ ) {
{'fraction_non_alphanumeric': 0.1567032967032967, 'fraction_numerical': 0.014505494505494506, 'mean_word_length': 2.6790622473726757, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '484903', 'n_tokens_mistral': 1563, 'n_tokens_neox': 1498, 'n_words': 306}