<commit_before>/* eslint no-unused-vars: 0 */

/***********************************/
/** data-calculate-row-identities **/
/***********************************/
gridState.processors['data-calculate-row-identities'] = {
    watches: ['data', 'columns'],
    runs: function (options) {
        if (!options.model.ui.selectable) {
            return;
        }
        var didChange = false;

        var identityColumns = options.model.columns.filter(function (col) {
            return col.isIdentity;
        }).sort(function (colA, colB) {
            return colA.id < colB.id ? -1 : 1;
        });

        options.model.data.forEach(function (row) {
            var identity = identityColumns.reduce(function (total, col) {
                return total + '_' + getCellData(row, col);
            }, '');
            var formattedIdentity = identity.replace(/[\s'".@+\-|]/g, '');
            if (row.$identity !== formattedIdentity) {
                didChange = true;
            }
            row.$identity = formattedIdentity;
        });

        if (options.model.logging && didChange) {
            console.log('Row identities calculated');
        }
    }
};

function getCellData(row, col) {
    return row[col.id];<commit_msg>Row identities are calculated when actions are present even if the grid does not support selection<commit_after>/* eslint no-unused-vars: 0 */

/***********************************/
/** data-calculate-row-identities **/
/***********************************/
gridState.processors['data-calculate-row-identities'] = {
    watches: ['data', 'columns'],
    runs: function (options) {
        if (!options.model.ui.selectable && (!options.model.ui.actions || options.model.ui.actions.length === 0)) {
            return;
        }
        var didChange = false;

        var identityColumns = options.model.columns.filter(function (col) {
            return col.isIdentity;
        }).sort(function (colA, colB) {
            return colA.id < colB.id ? -1 : 1;
        });

        options.model.data.forEach(function (row) {
            var identity = identityColumns.reduce(function (total, col) {
                return total + '_' + getCellData(row, col);
            }, '');
            var formattedIdentity = identity.replace(/[\s'".@+\-|]/g, '');
            if (row.$identity !== formattedIdentity) {
                didChange = true;
            }
            row.$identity = formattedIdentity;
        });

        if (options.model.logging && didChange) {
            console.log('Row identities calculated');
        }
    }
};

function getCellData(row, col) {
    return row[col.id];
{'fraction_non_alphanumeric': 0.1942227290003801, 'fraction_numerical': 0.0026605853287723297, 'mean_word_length': 2.167268351383875, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2486304', 'n_tokens_mistral': 735, 'n_tokens_neox': 712, 'n_words': 145}