<commit_before>'use strict';

var fetch = require('node-fetch'),
    winston = require('winston'),
    moment = require('moment');

module.exports = function (slackHook, slackChannel) {
    return function (res) {
        return res.json()
            .then(function (json) {
                var reqBody = JSON.stringify({
                    attachments: [{
                        fallback: 'Uploaded ' + json.name + ' to TestBuild.rocks',
                        pretext: 'Uploaded ' + json.name + ' to TestBuild.rocks',
                        title: json.name,
                        title_link: json.install,
                        color: 'good',
                        fields: [{
                            title: 'Version',
                            value: '' + json.version,
                            short: true
                        }, {
                            title: 'Build#',
                            value: '' + json.build,
                            short: true
                        }, {
                            title: 'Platform',
                            value: json.type,
                            short: true
                        }, {
                            title: 'Date',
                            value: moment.unix(json.date).format('llll'),
                            short: true
                        }, {
                            title: 'Comment',
                            value: json.comment
                        }],
                        image_url: json.qrcode,
                        thumb_url: json.iconurl
                    }],
                    channel: slackChannel
                });
                return fetch(slackHook, {
                    method: 'POST',
                    body: reqBody
                }).then(function (res) {
                    return { res: res, reqBody: reqBody };
                });
            }).then(function (_ref) {
                var res = _ref.res;
                var reqBody = _ref.reqBody;

                if (res.status == 200) {
                    winston.info('Sent to Slack');
                    return;
                }
                return res.text().then(function (body) {
                    throw new Error('Failed to send to slack (' + slackHook + ', ' + slackChannel + ') [' + body + '] [' + reqBody + ']');
                });
            });
    };
};<commit_msg>Add app server to fields when its set<commit_after>'use strict';

var fetch = require('node-fetch'),
    winston = require('winston'),
    moment = require('moment');

module.exports = function (slackHook, slackChannel) {
    return function (res) {
        return res.json()
            .then(function (json) {
                var data = {
                    attachments: [{
                        fallback: 'Uploaded ' + json.name + ' to TestBuild.rocks',
                        pretext: 'Uploaded ' + json.name + ' to TestBuild.rocks',
                        title: json.name,
                        title_link: json.install,
                        color: 'good',
                        fields: [{
                            title: 'Version',
                            value: '' + json.version,
                            short: true
                        }, {
                            title: 'Build#',
                            value: '' + json.build,
                            short: true
                        }, {
                            title: 'Platform',
                            value: json.type,
                            short: true
                        }, {
                            title: 'Date',
                            value: moment.unix(json.date).format('llll'),
                            short: true
                        }, {
                            title: 'Comment',
                            value: json.comment
                        }],
                        image_url: json.qrcode,
                        thumb_url: json.iconurl
                    }],
                    channel: slackChannel
                };

                if (json.appServer) {
                    data.attachments.fields.push({
                        title: 'Server',
                        value: json.appServer
                    });
                }

                var reqBody = JSON.stringify();
                return fetch(slackHook, {
                    method: 'POST',
                    body: reqBody
                }).then(function (res) {
                    return { res: res, reqBody: reqBody };
                });
            }).then(function (_ref) {
                var res = _ref.res;
                var reqBody = _ref.reqBody;

                if (res.status == 200) {
                    winston.info('Sent to Slack');
                    return;
                }
                return res.text().then(function (body) {
                    throw new Error('Failed to send to slack (' + slackHook + ', ' + slackChannel + ') [' + body + '] [' + reqBody + ']');
                });
            });
    };
};
{'fraction_non_alphanumeric': 0.10545881432205048, 'fraction_numerical': 0.0011739385638818234, 'mean_word_length': 0.806998939554613, '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': '4386480', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1097, 'n_words': 250}