Skip to content

Commit

Permalink
Fix incorrect count in subscriber query when there are no results.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Aug 1, 2024
1 parent 45f1f80 commit fedc515
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ SELECT COUNT(*) AS total FROM subscribers

-- name: query-subscribers-count-all
-- Cached query for getting the "all" subscriber count without arbitrary conditions.
SELECT SUM(subscriber_count) AS total FROM mat_list_subscriber_stats
SELECT COALESCE(SUM(subscriber_count), 0) AS total FROM mat_list_subscriber_stats
WHERE list_id = ANY(CASE WHEN CARDINALITY($1::INT[]) > 0 THEN $1 ELSE '{0}' END)
AND ($2 = '' OR status = $2::subscription_status);

Expand Down

0 comments on commit fedc515

Please sign in to comment.