<commit_before>let cache = {};
let telegramService = require('./telegram-service');
let Promise = require('bluebird');

class BuildService {

    getBuild(projectId) {
        return cache[projectId];
    }

    setBuild(build) {
        cache[build.project_id] = build;
    }

    didLastBuildSucceed(projectId) {
        let build = this.getBuild(projectId);
        return build ? build.status == 'success' : true;
    }

    clear() {
        cache = {};
    }

    onBuild(build, chatId, mode, format) {
        // Just listen for success and errors
        if (build.status != 'success' && build.status != 'error') {
            return Promise.resolve();
        }

        if (mode != 'all') {
            let success = this.didLastBuildSucceed(build.project_id);
            this.setBuild(build);

            // Did last build succeed
            if (build.status != 'error' && success) {
                return Promise.resolve();
            }
        }

        return telegramService.send(chatId, build, format);
    }

}

module.exports = new BuildService();<commit_msg>Type check for strings<commit_after>let cache = {};
let telegramService = require('./telegram-service');
let Promise = require('bluebird');

class BuildService {

    getBuild(projectId) {
        return cache[projectId];
    }

    setBuild(build) {
        cache[build.project_id] = build;
    }

    didLastBuildSucceed(projectId) {
        let build = this.getBuild(projectId);
        return build ? build.status === 'success' : true;
    }

    clear() {
        cache = {};
    }

    onBuild(build, chatId, mode, format) {
        // Just listen for success and errors
        if (build.status !== 'success' && build.status !== 'error') {
            return Promise.resolve();
        }

        if (mode !== 'all') {
            let success = this.didLastBuildSucceed(build.project_id);
            this.setBuild(build);

            // Did last build succeed
            if (build.status !== 'error' && success) {
                return Promise.resolve();
            }
        }

        return telegramService.send(chatId, build, format);
    }

}

module.exports = new BuildService();

{'fraction_non_alphanumeric': 0.13067400275103164, 'fraction_numerical': 0.0, 'mean_word_length': 2.068917018284107, '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': '4912068', 'n_tokens_mistral': 625, 'n_tokens_neox': 606, 'n_words': 138}