profile_mail.js 1.73 KB
const mail = require('../../models/mail');
const moment = require('moment');

function reporter(data, cb) {
    const mailOptions = {
        from: 'automan@yoho.cn',
        to: 'webtech@yoho.cn',
        // to: 'tao.huang@yoho.cn',
        subject: `线上项目错误结果最近三天结果汇总 ` + moment().format('YYYY-MM-DD HH:mm:ss'),
        html: tpl(data['yohobuy-node']) + tpl(data['yohobuywap-node'])
    };

    mail.sendMail(mailOptions, cb)
}

function tpl ({name, one, two, three}) {
    return `<div style="margin-bottom: 20px">
	<div style="font-size: 20px">${name}</div>
            <table border=="1">
                <thead>
                    <td></td>
                    <td>${one.time}</td>
                    <td>${two.time}</td>
                    <td>${three.time}</td>
                </thead>
                <tbody>
                    <tr>
                        <td>前端</td>
                        <td>${one.client}</td>
                        <td>${two.client}</td>
                        <td>${three.client}</td>
                    </tr> 
                    <tr>
                        <td>后端</td>
                        <td>${one.server}</td>
                        <td>${two.server}</td>
                        <td>${three.server}</td>
                    </tr>
                    <tr>
                        <td>接口</td>
                        <td>${one.api}</td>
                        <td>${two.api}</td>
                        <td>${three.api}</td>
                    </tr> 
                </tbody>
            </table>
            <div><a href="http://node-ci.yohops.com/profile/error">点这里去 node-ci 查看</a></div>
            
            </div>`
}

module.exports = {
    reporter
};