From: Andrew Engelbrecht Date: Thu, 18 May 2023 22:12:53 +0000 (-0400) Subject: list board forum eligible participants X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=523c32dccd1176eb742cb8985b86bc61f01eb020;p=civicrm-scripts.git list board forum eligible participants --- diff --git a/board-forum-contacts.sql b/board-forum-contacts.sql new file mode 100644 index 0000000..98079d2 --- /dev/null +++ b/board-forum-contacts.sql @@ -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; +