<commit_before>function getRatioPercent(ratio) {
    return (ratio * 100).toFixed(1) + "%";
}

function _initTasks_sub(li, tasks) {
    if (tasks) {
        var ul = $('<ul></ul>');
        for (const [key, task] of Object.entries(tasks)) {
            var liTask = $('<li></li>').text(getRatioPercent(task.ratio) + " " + key);
            _initTasks_sub(liTask, task.tasks);
            ul.append(liTask);
        }
        li.append(ul);
    }
}

function _getTasks_div(root, title) {
    var taskDiv = $('<div></div>');
    var taskDivHeading = $('<h3></h3>').text(title);
    taskDiv.append(taskDivHeading);
    var ulClasses = $('<ul></ul>');
    for (const [key, clazz] of Object.entries(root)) {
        var liClass = $('<li></li>').text(getRatioPercent(clazz.ratio) + " " + key);
        _initTasks_sub(liClass, clazz.tasks)
        ulClasses.append(liClass);
    }
    taskDiv.append(ulClasses);
    return taskDiv
}


function updateTasks() {
    $.get('/tasks', function (data) {
        var tasks = $('#tasks .tasks');
        tasks.empty();
        tasks.append(_getTasks_div(data.per_class, 'Ratio per User class'));
        tasks.append(_getTasks_div(data.total, 'Total ratio'));
    });
}
updateTasks();<commit_msg>#1994 Fixing to fallback in case of local execution<commit_after>function getRatioPercent(ratio) {
    return (ratio * 100).toFixed(1) + "%";
}

function _initTasks_sub(li, tasks) {
    if (tasks) {
        var ul = $('<ul></ul>');
        for (const [key, task] of Object.entries(tasks)) {
            var liTask = $('<li></li>').text(getRatioPercent(task.ratio) + " " + key);
            _initTasks_sub(liTask, task.tasks);
            ul.append(liTask);
        }
        li.append(ul);
    }
}

function _getTasks_div(root, title) {
    var taskDiv = $('<div></div>');
    var taskDivHeading = $('<h3></h3>').text(title);
    taskDiv.append(taskDivHeading);
    var ulClasses = $('<ul></ul>');
    for (const [key, clazz] of Object.entries(root)) {
        var liClass = $('<li></li>').text(getRatioPercent(clazz.ratio) + " " + key);
        _initTasks_sub(liClass, clazz.tasks)
        ulClasses.append(liClass);
    }
    taskDiv.append(ulClasses);
    return taskDiv
}

function renderTasks(data) {
    var tasks = $('#tasks .tasks');
    tasks.empty();
    tasks.append(_getTasks_div(data.per_class, 'Ratio per User class'));
    tasks.append(_getTasks_div(data.total, 'Total ratio'));
}

function updateTasks() {
    $.get('/tasks', function (data) {
        renderTasks(data);
    }).fail(function() {
        // fallback issue #1994
        renderTasks($('#tasks .tasks').data('tasks'));
    });
}
updateTasks();
{'fraction_non_alphanumeric': 0.1850037678975132, 'fraction_numerical': 0.007535795026375283, 'mean_word_length': 2.945022288261516, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '4474812', 'n_tokens_mistral': 889, 'n_tokens_neox': 875, 'n_words': 166}