<commit_before>/**
 * Refreshes the table data every 5 seconds
 * @param updateTableUrl
 *          url to update complete table (method updateTableMethod within BatchActivityController)
 * @param checkUrl
 *          url to check if active BatchActivities exist (method checkForUpdate within BatchActivityController)
 * @param rowUpdateUrl
 *          url to update all rows (method getUpdate within BatchActivityController)
 */
function updateIfNecessary(updateTableUrl, checkUrl, rowUpdateUrl) {
    setInterval(function () {
        var ids = collectActiveIds();

        if (ids.length == 0 && isPageOne()) {
            jQuery.ajax({
                type: 'GET',
                url: checkUrl,
                success: function (content) {
                    if (content == "true") {
                        updateBatchActivityTable(updateTableUrl);
                    }
                }
            });
        } else {
            updateRows(ids,rowUpdateUrl);
        }
    }, 5000);
}

/**
 * updates the batchActivity table
 * @param updateTableUrl url to updateTableMethod within BatchActivityController
 */
function updateBatchActivityTable(updateTableUrl) {
    jQuery.ajax({
        type: 'GET',
        url: updateTableUrl,
        success: function (content) {
            $("#tabelle").html(content);
        },
        error: function (content) {
        }
    });
}

/**
 * Replaces all rows with the given id with a new version
 * @param ids row ids to update
 * @param rowUpdateUrl url to get a row update
 */
function updateRows(ids, rowUpdateUrl) {

    jQuery.ajax({
        type: 'GET',
        url: rowUpdateUrl,
        traditional: true,
        data: {activeIds: ids},
        async: false,
        success: function (content) {
            $.each(content, function(i, update){
                updateRow(update);
            });
        },
        error: function (content) {
        }
    });

}
/**
 * Checks if active page is page 1
 * @returns {boolean}
 */
function isPageOne() {
    var content = $(".active").text();
    return content == "1";
}
/**
 * replaces a single row with the given id with the content
 * @param id
 * @param content
 */
function updateRow(rowObject) {
    console.log("will be activated: " + JSON.stringify(rowObject));
    var idxFieldActivity = 1;
    var idxFieldStatus = 2;
    var idxFieldProgress = 3;
    var idxFieldLastFailureMessage = 4;
    var idxFieldLastUpdated = 6;
    var idxFieldEndDate = 7;

    $("tr#" + rowObject.htmlId + " td:eq("+idxFieldActivity+")").html(rowObject.activity);
    $("tr#" + rowObject.htmlId + " td:eq("+idxFieldStatus+")").html(rowObject.status);
    $("tr#" + rowObject.htmlId + " td:eq("+idxFieldProgress+")").html(rowObject.progress);<commit_msg>Updated comments<commit_after>/**
 * Refreshes the table data every 5 seconds
 * @param updateTableUrl
 *          url to update complete table (method updateTableMethod within BatchActivityController)
 * @param checkUrl
 *          url to check if active BatchActivities exist (method checkForUpdate within BatchActivityController)
 * @param rowUpdateUrl
 *          url to update all rows (method getUpdate within BatchActivityController)
 */
function updateIfNecessary(updateTableUrl, checkUrl, rowUpdateUrl) {
    setInterval(function () {
        var ids = collectActiveIds();

        if (ids.length == 0 && isPageOne()) {
            jQuery.ajax({
                type: 'GET',
                url: checkUrl,
                success: function (content) {
                    if (content == "true") {
                        updateBatchActivityTable(updateTableUrl);
                    }
                }
            });
        } else {
            updateRows(ids,rowUpdateUrl);
        }
    }, 5000);
}

/**
 * updates the batchActivity table
 * @param updateTableUrl url to updateTableMethod within BatchActivityController
 */
function updateBatchActivityTable(updateTableUrl) {
    jQuery.ajax({
        type: 'GET',
        url: updateTableUrl,
        success: function (content) {
            $("#tabelle").html(content);
        },
        error: function (content) {
        }
    });
}

/**
 * Updates all rows with the given ids
 * @param ids row ids to update
 * @param rowUpdateUrl url to get a row update
 */
function updateRows(ids, rowUpdateUrl) {

    jQuery.ajax({
        type: 'GET',
        url: rowUpdateUrl,
        traditional: true,
        data: {activeIds: ids},
        async: false,
        success: function (content) {
            $.each(content, function(i, update){
                updateRow(update);
            });
        },
        error: function (content) {
        }
    });

}
/**
 * Checks if active page is page 1
 * @returns {boolean}
 */
function isPageOne() {
    var content = $(".active").text();
    return content == "1";
}
/**
 * Updates a single row with the given rowObject
 * @param rowObject([activity,endDate,htmlId,lastFailureMessage,lastUpdated,progress,startDate,status])
 */
function updateRow(rowObject) {
    console.log("will be activated: " + JSON.stringify(rowObject));
    var idxFieldActivity = 1;
    var idxFieldStatus = 2;
    var idxFieldProgress = 3;
    var idxFieldLastFailureMessage = 4;
    var idxFieldLastUpdated = 6;
    var idxFieldEndDate = 7;

    $("tr#" + rowObject.htmlId + " td:eq("+idxFieldActivity+")").html(rowObject.activity);
    $("tr#" + rowObject.htmlId + " td:eq("+idxFieldStatus+")").html(rowObject.status);
    $("tr#" + rowObject.htmlId + " td:eq("+idxFieldProgress+")").html(rowObject.progress);
{'fraction_non_alphanumeric': 0.11964735516372796, 'fraction_numerical': 0.005037783375314861, 'mean_word_length': 2.4336009882643608, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4647736', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1521, 'n_words': 411}