<commit_before>var ImageMetaInformationModel = require('./model/ImageMetaInformationModel');
var fs = require('fs-extra');
var path = require('path');
var logger = require('winston');
var ImageManipulator = require('./ImageManipulator');
var config = require('./configurationLoader');

/**
 * Constructor.
 * **/
var ImageManipulatorRepository = function () {
    this.imageManipulator = new ImageManipulator();
};

/* ----- Methods ----- */

/**
 * Deletes an image set. It will be removed from the image meta information structure, the structure will be saved to file
 * and the images will be deleted.
 *
 * @param id The id of the image set.
 * @param callback Called when the complete deletion process is done. Has the updated image meta information model object as parameter.
 * **/
ImageManipulatorRepository.prototype.deleteImageSet = function (id, callback) {
    var imageSet = ImageMetaInformationModel.getImageSetById(id);

    // Delete image which are part of the set
    this.__deleteFile(imageSet.getReferenceImage().getPath());
    this.__deleteFile(imageSet.getNewImage().getPath());
    this.__deleteFile(imageSet.getDiffImage().getPath());

    // Delete information about the data set and save the information
    ImageMetaInformationModel.deleteImageSet(id);
    ImageMetaInformationModel.calculateBiggestDifferences();
    ImageMetaInformationModel.setTimeStamp(new Date().toISOString());
    ImageMetaInformationModel.save();

    logger.info('Deleted image set with id:', id);

    // Call callback when stuff is done
    if(callback){
        callback(ImageMetaInformationModel);
    }
};

/**
 * Creates diff images for all images with the same name in the reference/new folders.
 *
 * @param callback Called when the complete deletion process is done. Has the updated image meta information model object as parameter.
 * **/
ImageManipulatorRepository.prototype.calculateDifferencesForAllImages = function (autoCrop, pixDiffThreshold, distThreshold, callback) {
    logger.info('---------- Start ----------', new Date().toISOString());
    var autoCropValue = autoCrop ? autoCrop :config.getAutoCropOption();
    var pixDiffThresholdValue = pixDiffThreshold ? pixDiffThreshold : config.getMaxPixelDifferenceThreshold();
    var distThresholdValue = distThreshold ? distThreshold : config.getMaxDistanceDifferenceThreshold();

    logger.info("----- Options Start -----");
    logger.info("Auto cropping is enabled: ", autoCropValue);
    logger.info("Threshold for pixel difference:", pixDiffThresholdValue);
    logger.info("Distance threshold:", distThresholdValue);
    logger.info("----- Options End -----");

    // Clears the old meta information model to start from a clean plate and avoid invalite states
    ImageMetaInformationModel.clear();

    // Creating diff images
    this.imageManipulator.createDiffImages(autoCropValue, pixDiffThresholdValue, distThresholdValue, function (metaInformationModel) {
        logger.info('---------- End ----------', new Date().toISOString());
        if(callback){
            var isbiggestDistanceDiffThresholdBreached = metaInformationModel.getBiggestDistanceDifference()  <= distThresholdValue;
            var isbiggestPixelDiffThresholdBreached = metaInformationModel.getBiggestPercentualPixelDifference()  <= pixDiffThresholdValue;

            callback(metaInformationModel, isbiggestDistanceDiffThresholdBreached && isbiggestPixelDiffThresholdBreached);
        }
    });
};
<commit_msg>Adds some mre logger statements.<commit_after>var ImageMetaInformationModel = require('./model/ImageMetaInformationModel');
var fs = require('fs-extra');
var path = require('path');
var logger = require('winston');
var ImageManipulator = require('./ImageManipulator');
var config = require('./configurationLoader');

/**
 * Constructor.
 * **/
var ImageManipulatorRepository = function () {
    this.imageManipulator = new ImageManipulator();
};

/* ----- Methods ----- */

/**
 * Deletes an image set. It will be removed from the image meta information structure, the structure will be saved to file
 * and the images will be deleted.
 *
 * @param id The id of the image set.
 * @param callback Called when the complete deletion process is done. Has the updated image meta information model object as parameter.
 * **/
ImageManipulatorRepository.prototype.deleteImageSet = function (id, callback) {
    var imageSet = ImageMetaInformationModel.getImageSetById(id);

    // Delete image which are part of the set
    this.__deleteFile(imageSet.getReferenceImage().getPath());
    this.__deleteFile(imageSet.getNewImage().getPath());
    this.__deleteFile(imageSet.getDiffImage().getPath());

    // Delete information about the data set and save the information
    ImageMetaInformationModel.deleteImageSet(id);
    ImageMetaInformationModel.calculateBiggestDifferences();
    ImageMetaInformationModel.setTimeStamp(new Date().toISOString());
    ImageMetaInformationModel.save();

    logger.info('Deleted image set with id:', id);

    // Call callback when stuff is done
    if(callback){
        callback(ImageMetaInformationModel);
    }
};

/**
 * Creates diff images for all images with the same name in the reference/new folders.
 *
 * @param callback Called when the complete deletion process is done. Has the updated image meta information model object as parameter.
 * **/
ImageManipulatorRepository.prototype.calculateDifferencesForAllImages = function (autoCrop, pixDiffThreshold, distThreshold, callback) {
    logger.info('---------- Start ----------', new Date().toISOString());
    var autoCropValue = autoCrop ? autoCrop :config.getAutoCropOption();
    var pixDiffThresholdValue = pixDiffThreshold ? pixDiffThreshold : config.getMaxPixelDifferenceThreshold();
    var distThresholdValue = distThreshold ? distThreshold : config.getMaxDistanceDifferenceThreshold();

    logger.info("----- Options Start -----");
    logger.info("Auto cropping is enabled: ", autoCropValue);
    logger.info("Threshold for pixel difference:", pixDiffThresholdValue);
    logger.info("Distance threshold:", distThresholdValue);
    logger.info("----- Options End -----");

    // Clears the old meta information model to start from a clean plate and avoid invalite states
    ImageMetaInformationModel.clear();

    // Creating diff images
    this.imageManipulator.createDiffImages(autoCropValue, pixDiffThresholdValue, distThresholdValue, function (metaInformationModel) {
        logger.info('---------- End ----------', new Date().toISOString());
        if(callback){
            var isbiggestDistanceDiffThresholdBreached = metaInformationModel.getBiggestDistanceDifference()  <= distThresholdValue;
            var isbiggestPixelDiffThresholdBreached = metaInformationModel.getBiggestPercentualPixelDifference()  <= ;

            logger.info("Percentual pixel difference:"
                + "\nThreshold breached " + isbiggestPixelDiffThresholdBreached
                + "\nAllowed threshold: " + pixDiffThresholdValue
                + "\nDifference:" + metaInformationModel.getBiggestPercentualPixelDifference());

            logger.info("Distance difference:"
                + "\nThreshold breached " + isbiggestDistanceDiffThresholdBreached
                + "\nAllowed threshold: " + distThresholdValue
                + "\nDifference:" + metaInformationModel.getBiggestDistanceDifference());

            callback(metaInformationModel, isbiggestDistanceDiffThresholdBreached && isbiggestPixelDiffThresholdBreached);
        }
    });
};

{'fraction_non_alphanumeric': 0.11308970099667774, 'fraction_numerical': 0.0, 'mean_word_length': 3.9808074123097286, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5377490', 'n_tokens_mistral': 1890, 'n_tokens_neox': 1819, 'n_words': 518}