<commit_before>'use strict';

const _ = require('lodash');

/**
 * Get the relevance score for the given cachedResult (based on this score, irrelevant entries are removed)
 * @param {CachedResult} result
 * @param {CachedResult[]} [allResults]
 * @returns {Number}
 */
module.exports = (result, allResults) => {

    // Substract one point for every month in age
    let age = result.created / (31 * 24 * 60 * 60 * 1000);

    // Substract one point for every order of magnitude in filesize
    let size = -Math.log10(result.fileSize);

    // Add two points for every order of magnitude in operation runtime
    let runtime = Math.log10(result.runtime) * 2;

    // Remove 20 points if there is a newer entry with an equivalent action name in the index
    let redundant = allResults && allResults.length ? (_.some(allResults, otherResult => {
        return otherResult.action == result.action && otherResult.created > result.created;
    }) ? -20 : 0) : 0;

    // Add all factors that are a number (to protect against NaN screwing everything up)
    return _.reduce([age, size, runtime, redundant], (total, add) => _.isNumber(add) ? total + add : total, 0);
};<commit_msg>fix lint error<commit_after>'use strict';

const _ = require('lodash');

/**
 * Get the relevance score for the given cachedResult (based on this score, irrelevant entries are removed)
 * @param {CachedResult} result
 * @param {CachedResult[]} [allResults]
 * @returns {Number}
 */
module.exports = (result, allResults) => {

    // Substract one point for every month in age
    let age = result.created / (31 * 24 * 60 * 60 * 1000);

    // Substract one point for every order of magnitude in filesize
    let size = -Math.log10(result.fileSize);

    // Add two points for every order of magnitude in operation runtime
    let runtime = Math.log10(result.runtime) * 2;

    // Remove 20 points if there is a newer entry with an equivalent action name in the index
    let redundant = allResults && allResults.length ? (_.some(allResults, otherResult => {
        return otherResult.action === result.action && otherResult.created > result.created;
    }) ? -20 : 0) : 0;

    // Add all factors that are a number (to protect against NaN screwing everything up)
    return _.reduce([age, size, runtime, redundant], (total, add) => _.isNumber(add) ? total + add : total, 0);
};
{'fraction_non_alphanumeric': 0.11512319456244689, 'fraction_numerical': 0.020390824129141887, 'mean_word_length': 3.4018691588785046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2948996', 'n_tokens_mistral': 708, 'n_tokens_neox': 643, 'n_words': 266}