Fix next-campaigns query to return campaign_ids with 0 counts as well when there were 0 subscribers in target_lists. This would result in started_at never being updated in the update sub query.
This commit is contained in:
parent
d712afff97
commit
1473961ef0
12
queries.sql
12
queries.sql
|
@ -198,12 +198,12 @@ WITH camps AS (
|
||||||
),
|
),
|
||||||
counts AS (
|
counts AS (
|
||||||
-- For each campaign above, get the total number of subscribers and the max_subscriber_id across all its lists.
|
-- For each campaign above, get the total number of subscribers and the max_subscriber_id across all its lists.
|
||||||
SELECT campaign_id, COUNT(subs.id) as to_send, COALESCE(MAX(subs.id), 0) as max_subscriber_id
|
SELECT id AS campaign_id, COUNT(subscriber_lists.subscriber_id) AS to_send,
|
||||||
FROM subscribers subs, subscriber_lists sublists, campaign_lists camplists
|
COALESCE(MAX(subscriber_lists.subscriber_id), 0) AS max_subscriber_id FROM camps
|
||||||
WHERE sublists.list_id = camplists.list_id AND
|
LEFT JOIN campaign_lists ON (campaign_lists.campaign_id = camps.id)
|
||||||
subs.id = sublists.subscriber_id
|
LEFT JOIN subscriber_lists ON (subscriber_lists.list_id = campaign_lists.list_id)
|
||||||
AND camplists.campaign_id = ANY(SELECT id FROM camps)
|
WHERE campaign_lists.campaign_id = ANY(SELECT id FROM camps)
|
||||||
GROUP BY camplists.campaign_id
|
GROUP BY camps.id
|
||||||
),
|
),
|
||||||
u AS (
|
u AS (
|
||||||
-- For each campaign above, update the to_send count.
|
-- For each campaign above, update the to_send count.
|
||||||
|
|
Loading…
Reference in New Issue