Skip to content

Commit ff6b3ea

Browse files
committed
drop in score
1 parent a96ed56 commit ff6b3ea

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

lib/commands/cron.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ const addLog = async (page)=>{
4242
const results = {};
4343
for (const category of cateogires) {
4444
const element = category=="best-practices"?"bestPractices":category;
45-
const score = res.lighthouseResult.categories[category].score*100;
45+
const score = Math.floor(res.lighthouseResult.categories[category].score*100);
4646
if (averages[strategy][element]) {
47-
if ((averages[strategy][element]-score)>config.allowed_drop) {
47+
const diff =Math.floor(averages[strategy][element]-score);
48+
if (diff > config.allowed_drop) {
4849
if (config.alert) {
4950
sendAlert({
5051
category: element,
@@ -53,6 +54,7 @@ const addLog = async (page)=>{
5354
score: score,
5455
page: page.name,
5556
url: page.url,
57+
diff: diff,
5658
});
5759
}
5860
}
@@ -86,7 +88,7 @@ async function sendAlert(alert) {
8688
const mailOptions = {
8789
from: config.email_user,
8890
to: config.email_to,
89-
subject: `[charizard][alert] drop in ${alert.category} score in ${alert.page} page`,
91+
subject: `[charizard][alert] drop in ${alert.category} score ${alert.diff} in ${alert.page} page`,
9092
html: template,
9193
};
9294
transporter.sendMail(mailOptions, function(error, info) {

lib/email/template.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tr:nth-child(even){background-color: #f2f2f2}
2323
</head>
2424
<body>
2525

26-
<h2><span class="red">ALERT:</span> Drop in <%=category%> score '<%=score%>%' in <%=page%> page</h2>
26+
<h2><span class="red">ALERT:</span> Drop in <%=category%> score '<%=diff%>%' in <%=page%> page</h2>
2727

2828
<div style="overflow-x:auto;">
2929
<table>

0 commit comments

Comments
 (0)