BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr
Optimized click rate calculate logic.
Jack48aa34b80f41
diff --git a/core/internal/service/maillog_stat/overview.go b/core/internal/service/maillog_stat/overview.goindex d3e201d1..d7173a82 100644--- a/core/internal/service/maillog_stat/overview.go+++ b/core/internal/service/maillog_stat/overview.go@@ -593,6 +593,13 @@ func (o *Overview) chartClickRate(campaignID int64, domain string, startTime, encolumnType, xAxisField := o.prepareChartData(startTime, endTime)+ query.LeftJoin(`LATERAL(+ SELECT id+ FROM mailstat_opened+ WHERE sm.postfix_message_id = postfix_message_id+ LIMIT 1+) as o`, "true")+query.LeftJoin(`LATERAL(SELECT idFROM mailstat_clicked@@ -601,7 +608,7 @@ func (o *Overview) chartClickRate(campaignID int64, domain string, startTime, en) as c`, "true")query.Fields(xAxisField)- query.Fields("case when coalesce(sum(case when status='sent' and dsn like '2.%' then 1 else 0 end), 0) > 0 then round(1.0 * count(c.id) / coalesce(sum(case when status='sent' and dsn like '2.%' then 1 else 0 end), 0) * 100, 2) else 0.0 end as click_rate")+ query.Fields("case when count(o.id) > 0 then round(1.0 * count(c.id) / count(o.id) * 100, 2) else 0.0 end as click_rate")query.Group("x")