From 138b486b2f87ee0917a8d1ada2113ce1d8e4ec41 Mon Sep 17 00:00:00 2001 From: Jordan Wright Date: Fri, 27 Mar 2020 21:29:41 -0500 Subject: [PATCH] Caching the campaign for those that are launched immediately. This is related to #1726 --- worker/worker.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/worker/worker.go b/worker/worker.go index c4f2f1f0..76603edf 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -125,6 +125,11 @@ func (w *DefaultWorker) LaunchCampaign(c models.Campaign) { // that implements an interface as a slice of that interface. mailEntries := []mailer.Mail{} currentTime := time.Now().UTC() + campaignMailCtx, err := models.GetCampaignMailContext(c.Id, c.UserId) + if err != nil { + log.Error(err) + return + } for _, m := range ms { // Only send the emails scheduled to be sent for the past minute to // respect the campaign scheduling options @@ -132,7 +137,7 @@ func (w *DefaultWorker) LaunchCampaign(c models.Campaign) { m.Unlock() continue } - err = m.CacheCampaign(&c) + err = m.CacheCampaign(&campaignMailCtx) if err != nil { log.Error(err) return