list board forum eligible participants
authorAndrew Engelbrecht <andrew@fsf.org>
Thu, 18 May 2023 22:12:53 +0000 (18:12 -0400)
committerAndrew Engelbrecht <andrew@fsf.org>
Thu, 18 May 2023 22:12:53 +0000 (18:12 -0400)
board-forum-contacts.sql [new file with mode: 0644]

diff --git a/board-forum-contacts.sql b/board-forum-contacts.sql
new file mode 100644 (file)
index 0000000..98079d2
--- /dev/null
@@ -0,0 +1,32 @@
+
+-- SPDX-FileCopyrightText: 2023 Andrew Engelbrecht
+--
+-- SPDX-License-Identifier: GPL-3.0-or-later
+
+select c.id from civicrm_contact c
+where c.is_deleted = 0
+and c.id not in (
+    select contact_id from civicrm_group_contact
+    where id = 1978 and status = 'Added' -- adhoc exclusion group
+) and (
+    c.id in (
+        select contact_id from civicrm_group_contact
+        where id = 1977 and status = 'Added' -- adhoc inclusion group
+    ) or (
+        c.id in (
+            select contact_id from civicrm_membership
+            where status_id in (1, 2, 3) -- is a member: new, current or grace
+        ) and (
+            c.id in (
+                select contact_id from civicrm_membership
+                where status_id in (1, 2, 3, 4) and end_date >= '2018-01-19' and start_date <= '2022-10-19' -- was a member during time period
+            ) or c.id in (
+                select contact_id from civicrm_contribution
+                where contribution_status_id = 1 and receive_date >= '2018-01-19' and receive_date <= '2022-10-19'
+                group by contact_id
+                having sum(total_amount) > '120.00' -- donated $120 or more during time period
+            )
+        )
+    )
+) order by id asc;
+