<commit_before>var CronJob = require('cron').CronJob,

    logger = require('./logger'),
    TargetNodes = require('./targets/nodes').TargetNodes,

    job,
    state,

    STATE = {
        IDLE: 0,
        ACTIVE: 1
    };

function setIdle() {
    state = STATE.IDLE;
}

function setActive() {
    state = STATE.ACTIVE;
}

function isActive() {
    return state === STATE.ACTIVE;
}

function execute () {
    logger.info('=== CRON CHECK FOR DATA START ===', module);

    if (isActive()) {
        logger.warn('Previous synchronization process was not completed yet', module);
        return;
    }

    setActive();
    return (new TargetNodes({})).execute()
        .then(function () {
            setIdle();
            logger.info('=== CRON CHECK FOR DATA END ===', module);
        })
        .fail(function () {
            setIdle();
            logger.error('=== CRON CHECK FOR DATA ERROR ===', module);
        });
}

module.exports = {
    /**
     * Initialize cron job for commit and push tasks perform
     */
    init: function () {
        state = STATE.IDLE;
        job = new CronJob({
            cronTime: '0 */1 * * * *',
            onTick: execute,
            start: true<commit_msg>Remove creating multiple instances of target for execution<commit_after>var CronJob = require('cron').CronJob,

    logger = require('./logger'),
    TargetNodes = require('./targets/nodes').TargetNodes,

    job,
    state,
    target = new TargetNodes({}),

    STATE = {
        IDLE: 0,
        ACTIVE: 1
    };

function setIdle() {
    state = STATE.IDLE;
}

function setActive() {
    state = STATE.ACTIVE;
}

function isActive() {
    return state === STATE.ACTIVE;
}

function execute () {
    logger.info('=== CRON CHECK FOR DATA START ===', module);

    if (isActive()) {
        logger.warn('Previous synchronization process was not completed yet', module);
        return;
    }

    setActive();
    return target.execute()
        .then(function () {
            setIdle();
            logger.info('=== CRON CHECK FOR DATA END ===', module);
        })
        .fail(function () {
            setIdle();
            logger.error('=== CRON CHECK FOR DATA ERROR ===', module);
        });
}

module.exports = {
    /**
     * Initialize cron job for commit and push tasks perform
     */
    init: function () {
        state = STATE.IDLE;
        job = new CronJob({
            cronTime: '0 */1 * * * *',
            onTick: execute,
            start: true
{'fraction_non_alphanumeric': 0.14665592264302982, 'fraction_numerical': 0.0032232070910556, 'mean_word_length': 2.017010935601458, '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': '295610', 'n_tokens_mistral': 734, 'n_tokens_neox': 701, 'n_words': 194}