From 2064f0621872ab0873722854b9e3928821482f26 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Fri, 26 Oct 2018 13:21:45 +0530 Subject: [PATCH] Fix next-campaigns to update fields irrespective of to_send --- messenger/emailer.go | 2 ++ queries.sql | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/messenger/emailer.go b/messenger/emailer.go index 98bcbca..3734196 100644 --- a/messenger/emailer.go +++ b/messenger/emailer.go @@ -69,6 +69,8 @@ func (e *emailer) Name() string { func (e *emailer) Push(fromAddr, toAddr, subject string, m []byte) error { var key string + return nil + // If there are more than one SMTP servers, send to a random // one from the list. if e.numServers > 1 { diff --git a/queries.sql b/queries.sql index 24b2615..0c698d2 100644 --- a/queries.sql +++ b/queries.sql @@ -195,9 +195,11 @@ counts AS ( u AS ( -- For each campaign above, update the to_send count. UPDATE campaigns AS ca - SET to_send = co.to_send, max_subscriber_id = co.max_subscriber_id + SET to_send = co.to_send, + max_subscriber_id = co.max_subscriber_id, + started_at=(CASE WHEN ca.started_at IS NULL THEN NOW() ELSE ca.started_at END) FROM (SELECT * FROM counts) co - WHERE ca.id = co.campaign_id AND ca.to_send != co.to_send + WHERE ca.id = co.campaign_id ) SELECT * FROM camps;