<commit_before>const slaveService = require('../services/slave');
const versionService = require('../services/version');

const version = {
    currentVersion(req, res) {
        const {slaveUID, slaveVersion} = req.params,
            remoteAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress,
            tag = versionService.getCurrent();

        const respondWithTag = () => {
            res.json(200, {tag});
        };

        slaveService.updateSlave(slaveUID, slaveVersion, remoteAddress)
            .then(respondWithTag)
            .catch(error => {
                console.error(`An error occurred when updating ${slaveUID}: ${error}`);

                // send back current version regardless
                respondWithTag();
            });
    }
}

module.exports = version;<commit_msg>Send response while database is still updating<commit_after>const slaveService = require('../services/slave');
const versionService = require('../services/version');

const version = {
    currentVersion(req, res) {
        const {slaveUID, slaveVersion} = req.params,
            remoteAddress = req.headers['x-forwarded-for'] || req.connection.remoteAddress,
            tag = versionService.getCurrent();

        const respondWithTag = () => {
            res.json(200, {tag});
        };

        slaveService.updateSlave(slaveUID, slaveVersion, remoteAddress)
            .catch(error => {
                console.error(`An error occurred when updating ${slaveUID}: ${error}`);
            });

        // send back current version regardless of success or failure of db entry
        respondWithTag();
    }
}

module.exports = version;
{'fraction_non_alphanumeric': 0.12642300778909527, 'fraction_numerical': 0.0035949670461354103, 'mean_word_length': 2.4362139917695473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '487463', 'n_tokens_mistral': 425, 'n_tokens_neox': 413, 'n_words': 97}