Skip to content

Instantly share code, notes, and snippets.

@zoernert
Created September 16, 2021 22:36
Show Gist options
  • Select an option

  • Save zoernert/d13c05a0432e42dfee8cda6a9128d60b to your computer and use it in GitHub Desktop.

Select an option

Save zoernert/d13c05a0432e42dfee8cda6a9128d60b to your computer and use it in GitHub Desktop.
Calculating total CO2 Emission of MailStats
let totalco=0;
for(let i=0;i<mailStats.length;i++) {
for(let j=0;j<mailStats[i].stats.length;j++) {
for (const [key, value] of Object.entries(mailStats[i].stats[j].metrics)) {
if(key == "blocks") totalco2+=1
if(key == "bounce_drops") totalco2+=2
if(key == "bounces") totalco2+=2
if(key == "clicks") totalco2+=2
if(key == "deferred") totalco2+=2
if(key == "delivered") totalco2+=20
if(key == "invalid_emails") totalco2+=0
if(key == "opens") totalco2+=10
if(key == "processed") totalco2+=15
if(key == "requests") totalco2+=0
if(key == "spam_report_drops") totalco2+=1
if(key == "spam_reports") totalco2+=3
if(key == "unique_clicks") totalco2+=5
if(key == "unique_opens") totalco2+=5
if(key == "unsubscribe_drops") totalco2+=0
if(key == "unsubscribes") totalco2+=2
}
}
}
console.log('Total Co2 Emission in Gram',totalco2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment