Page MenuHomePhabricator

Suppress recurrings with only one charge from ty email receipt
Closed, ResolvedPublic4 Estimated Story Points

Description

Find a way to exclude donors who have a single recurring donation in 2024 (those who initiated a recurring donation in December or have had only one processed in 2024) from the thank you campaign.
Note: This has been approved by Mariana and legal.
Context: To better assist donors who may need help updating or canceling their donations, we’d like to minimize any unnecessary back-and-forth that arises from confusion caused by emails sent to one-time donors and deceased donors. Here are some examples:
CIDs 60803149, 39147378, and 47609686 each had only one donation in 2023 and received the summary receipt.

Event Timeline

SHust renamed this task from Suppress One-time-transactions and deceased donors from ty email receipt to Suppress One-time-transactions from ty email receipt .Nov 21 2024, 3:16 PM
SHust updated the task description. (Show Details)

There are a high volume of donations like this (Sandra has included a few examples above).

These are cases where an unintentional recurring donation was started and then cancelled but the supporter opted to leave the donation with us. They receive their initial receipt, however receiving the summary in January causes confusion in many cases - the donor wonders if their recurring was cancelled at all, they are worried they will get charged again etc.

Our goal is to filter for single recurring transactions - where a donor has made a single recurring gift then cancelled their recurring donations going forward, and suppress them from the TY summary.

Cstone renamed this task from Suppress One-time-transactions from ty email receipt to Suppress new in december recurring donations from ty email receipt .Dec 9 2024, 9:18 PM
Cstone renamed this task from Suppress new in december recurring donations from ty email receipt to Suppress recurrings with only one charge from ty email receipt .
Damilare set the point value for this task to 4.Dec 9 2024, 9:21 PM

Change #1107574 had a related patch set uploaded (by Eileen; author: Eileen):

[wikimedia/fundraising/crm@master] Remove old EOY data

https://gerrit.wikimedia.org/r/1107574

There are 2 ways to do this - with slightly different results

Baseline - current query as run on staging

INSERT INTO wmf_eoy_receipt_donor (year, email, status) SELECT 2024, email.email, 'queued'       
 FROM civicrm_contribution_recur contribution_recur               
 INNER JOIN civicrm_contribution contribution                           ON contribution.contribution_recur_id =
contribution_recur.id    
           INNER JOIN civicrm_email email                           
ON email.contact_id = contribution.contact_id
                     AND email.is_primary          
      INNER JOIN civicrm_contact contact ON contact.id = email.contact_id           
AND contact.is_deleted = 0              
  LEFT JOIN wmf_eoy_receipt_donor eoy ON email.email = eoy.email AND eoy.year = 2024       WHERE receive_date BETWEEN '2024-01-01 10:00:00' AND '2025-01-01 09:59:59'         AND contribution.contribution_status_id = 1         AND eoy.email IS NULL            AND contribution_recur.frequency_unit != 'year'     
 GROUP BY email.email;

Query OK, 892611 rows affected (5 min 31.411 sec)

  1. Alter the main query to this - I just tested on staging & it took 8 mins - although I did do this first https://gerrit.wikimedia.org/r/c/wikimedia/fundraising/crm/+/1107574?usp=dashboard

Query OK, 839155 rows affected (8 min 19.149 sec)

INSERT INTO wmf_eoy_receipt_donor (year, email, status)
SELECT 2024, email, 'queued'
FROM (SELECT email.email, count(*) as c
      FROM civicrm_contribution_recur contribution_recur
               INNER JOIN civicrm_contribution contribution
                          ON contribution.contribution_recur_id = contribution_recur.id
               INNER JOIN civicrm_email email
                          ON email.contact_id = contribution.contact_id
                              AND email.is_primary
               INNER JOIN civicrm_contact contact ON contact.id = email.contact_id
          AND contact.is_deleted = 0
               LEFT JOIN wmf_eoy_receipt_donor eoy ON email.email = eoy.email AND eoy.year = 2024
      WHERE receive_date BETWEEN '2024-01-01 10:00:00' AND '2025-01-01 09:59:59'
        AND contribution.contribution_status_id = 1
        AND eoy.email IS NULL
-- We exclude annual recurring contributions when deciding WHO to email.
-- if they have an annual recurring AND a monthly then both (all) donations
-- will still be included in the WHAT to email.
        AND contribution_recur.frequency_unit != 'year'
      GROUP BY email.email
      HAVING c > 1) as emails
  1. Run the original query and then DELETE any rows with only 1 contribution in the year

At the margin this will get more contacts - as the first query requires them to have more than 1 for any given recurring contribution (ie would not pick up 2 contributions against 2 separate attempts to set up recurring contributions). I think a case could be made either way - the 2 separate attempts would have had emails at the time

  • currently running this for timing
DELETE FROM wmf_eoy_receipt_donor WHERE email IN (
SELECT email FROM
                 (
SELECT d.email, count(c.id) as n FROM wmf_eoy_receipt_donor d
LEFT JOIN civicrm_email e ON e.email = d.email
    AND is_primary = 1
LEFT JOIN civicrm_contribution c ON e.contact_id = c.contact_id
  AND receive_date BETWEEN '2024-01-01 10:00:00' AND '2025-01-01 09:59:59'
  AND contribution_status_id = 1
  GROUP BY d.email
HAVING n < 2) as m);

That second one didn't get there but this worked

CREATE TABLE wmf_eoy_no_email (
    `email` varchar(254) DEFAULT NULL,
    INDEX email(email));

INSERT INTO wmf_eoy_no_email
SELECT email FROM
                 (
SELECT d.email, count(c.id) as n FROM wmf_eoy_receipt_donor d
LEFT JOIN civicrm_email e ON e.email = d.email
    AND is_primary = 1
-- this is a cheap way to drop out the ones that are on hold.
    AND on_hold = 0
LEFT JOIN civicrm_contribution c ON e.contact_id = c.contact_id
  AND receive_date BETWEEN '2024-01-01 10:00:00' AND '2025-01-01 09:59:59'
  AND contribution_status_id = 1
  GROUP BY d.email
HAVING n < 2) as m;

--- Query OK, 60242 rows affected (3 min 19.405 sec)


DELETE d FROM wmf_eoy_receipt_donor d INNER JOIN wmf_eoy_no_email e ON e.email = d.email;

--- Query OK, 60242 rows affected (1.423 sec)

DROP TABLE wmf_eoy_no_email;

Change #1108496 had a related patch set uploaded (by Eileen; author: Eileen):

[wikimedia/fundraising/crm@master] Update EOYMakeJob to exclude one-off

https://gerrit.wikimedia.org/r/1108496

We agreed on the option where we only include donors who have more than one donation on a single recurring record - meaning that they will have at least 1 unreceipted donation

Change #1107574 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Remove old EOY data

https://gerrit.wikimedia.org/r/1107574

Change #1108496 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Update EOYMakeJob to exclude one-off

https://gerrit.wikimedia.org/r/1108496

Eileenmcnaughton set Final Story Points to 4.