Skip to content

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

fix(batch_mail): add condition to filter email tasks based on stats update time

lotk968e6ad47938
diff --git a/core/internal/service/batch_mail/batch_mail.go b/core/internal/service/batch_mail/batch_mail.go
index a0bbc5da..59471db4 100644
--- a/core/internal/service/batch_mail/batch_mail.go
+++ b/core/internal/service/batch_mail/batch_mail.go
@@ -631,6 +631,7 @@ func UpdateTaskJoinMailstat(ctx context.Context) {
var tasksToUpdate []*entity.EmailTask
err := g.DB().Model("email_tasks").
Where("task_process IN (?)", []int{1, 3}).
+ WhereOr("task_process = 2 AND stats_update_time > ?", time.Now().Unix()-36*3600).
WhereOr("task_process = 2 AND sends_count < recipient_count*0.99").
WhereOr("stats_update_time", 0).
Order("id DESC").