<commit_before>/**
 * /api/services/HistoryService.js
 *
 * History service.
 */

/**
 * Method writes new history data. Note that we have to clone actual object
 * otherwise we will mess things up.
 *
 * @param   {String}    objectName  Name of the object eg. Task
 * @param   {Object}    object      Actual object
 */
exports.write = function(objectName, object) {
    var objectId = object.id;
    var objectData = _.clone(object);

    // Remove not needed "waste" data
    delete objectData.id;
    delete objectData.createdAt;
    delete objectData.updatedAt;

    // Create new history row
    History
        .create({
            objectId: objectId,
            objectName: objectName,
            objectData: JSON.stringify(objectData)
        })
        .done(function(error, data) {
        });
};<commit_msg>Added remove method to history service.<commit_after>/**
 * /api/services/HistoryService.js
 *
 * History service.
 */

/**
 * Method writes new history data. Note that we have to clone actual object
 * otherwise we will mess things up.
 *
 * @param   {String}    objectName  Name of the object eg. Task
 * @param   {Object}    object      Actual object
 */
exports.write = function(objectName, object) {
    var objectId = object.id;
    var objectData = _.clone(object);

    // Remove not needed "waste" data
    delete objectData.id;
    delete objectData.createdAt;
    delete objectData.updatedAt;

    // Create new history row
    History
        .create({
            objectId: objectId,
            objectName: objectName,
            objectData: JSON.stringify(objectData)
        })
        .done(function(error, data) {
        });
};

/**
 * Method removes all history data of specified object.
 *
 * @param   {String}    objectName  Name of the object eg. Task
 * @param   {Number}    objectId    ID of the object
 */
exports.remove = function(objectName, objectId) {
    // Remove all history rows
    History
        .destroy({
            objectId: objectId,
            objectName: objectName
        })
        .done(function(error, data) {
        });
};
{'fraction_non_alphanumeric': 0.10257633587786259, 'fraction_numerical': 0.0, 'mean_word_length': 2.2663551401869158, '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': '3842029', 'n_tokens_mistral': 584, 'n_tokens_neox': 578, 'n_words': 186}