Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Fix missing lists fetch in query-campaigns

Kailash Nadhb078c0006c4d
diff --git a/frontend/my/src/Campaign.js b/frontend/my/src/Campaign.js
index ba69d39b..88c46f58 100644
--- a/frontend/my/src/Campaign.js
+++ b/frontend/my/src/Campaign.js
@@ -387,8 +387,6 @@ class TheFormDef extends React.PureComponent {
}
}
- console.log(subLists)
-
if (this.record) {
this.props.pageTitle(record.name + " / Campaigns")
} else {
diff --git a/queries.sql b/queries.sql
index 14a0a6b3..ebe3d5aa 100644
--- a/queries.sql
+++ b/queries.sql
@@ -274,7 +274,13 @@ INSERT INTO campaign_lists (campaign_id, list_id, list_name)
-- there's a COUNT() OVER() that still returns the total result count
-- for pagination in the frontend, albeit being a field that'll repeat
-- with every resultant row.
-SELECT COUNT(*) OVER () AS total, campaigns.*
+SELECT COUNT(*) OVER () AS total, campaigns.*, (
+ SELECT COALESCE(ARRAY_TO_JSON(ARRAY_AGG(l)), '[]') FROM (
+ SELECT COALESCE(campaign_lists.list_id, 0) AS id,
+ campaign_lists.list_name AS name
+ FROM campaign_lists WHERE campaign_lists.campaign_id = campaigns.id
+ ) l
+ ) AS lists
FROM campaigns
WHERE ($1 = 0 OR id = $1)
AND status=ANY(CASE WHEN ARRAY_LENGTH($2::campaign_status[], 1) != 0 THEN $2::campaign_status[] ELSE ARRAY[status] END)