Skip to content

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

Fix incorrect count in subscriber query when there are no results.

Kailash Nadhfedc51514daf
diff --git a/queries.sql b/queries.sql
index 23cd3d28..9bed63ec 100644
--- a/queries.sql
+++ b/queries.sql
@@ -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);