Fix missing lists fetch in query-campaigns

This commit is contained in:
Kailash Nadh 2019-04-23 22:36:20 +05:30
parent 420c661d4d
commit b078c0006c
2 changed files with 7 additions and 3 deletions

View File

@ -387,8 +387,6 @@ class TheFormDef extends React.PureComponent {
} }
} }
console.log(subLists)
if (this.record) { if (this.record) {
this.props.pageTitle(record.name + " / Campaigns") this.props.pageTitle(record.name + " / Campaigns")
} else { } else {

View File

@ -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 -- there's a COUNT() OVER() that still returns the total result count
-- for pagination in the frontend, albeit being a field that'll repeat -- for pagination in the frontend, albeit being a field that'll repeat
-- with every resultant row. -- 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 FROM campaigns
WHERE ($1 = 0 OR id = $1) 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) AND status=ANY(CASE WHEN ARRAY_LENGTH($2::campaign_status[], 1) != 0 THEN $2::campaign_status[] ELSE ARRAY[status] END)