Mwalker has submitted this change and it was merged.
Change subject: (FR #986) mailing job to apologize for May 2013 PayPal
recurring fail.
......................................................................
(FR #986) mailing job to apologize for May 2013 PayPal recurring fail.
Incidentally created a "oneoffs" module to house this sorta stuff.
TODO: need the letter subject and body
Change-Id: Ic9ce7d36eeee0f9bbcbbdab65a578dd9f10d6b2c
---
A sites/all/modules/oneoffs/201305_paypal_recurring/SorryRecurringTemplate.php
A
sites/all/modules/oneoffs/201305_paypal_recurring/sorry_may2013_paypal_recurring.php
A sites/all/modules/oneoffs/oneoffs.drush.inc
A sites/all/modules/oneoffs/oneoffs.info
A sites/all/modules/oneoffs/oneoffs.module
5 files changed, 104 insertions(+), 0 deletions(-)
Approvals:
Mwalker: Verified; Looks good to me, approved
diff --git
a/sites/all/modules/oneoffs/201305_paypal_recurring/SorryRecurringTemplate.php
b/sites/all/modules/oneoffs/201305_paypal_recurring/SorryRecurringTemplate.php
new file mode 100644
index 0000000..436cb1a
--- /dev/null
+++
b/sites/all/modules/oneoffs/201305_paypal_recurring/SorryRecurringTemplate.php
@@ -0,0 +1,13 @@
+<?php
+
+use wmf_communication\AbstractMailingTemplate;
+
+class SorryRecurringTemplate extends AbstractMailingTemplate {
+ function getTemplateName() {
+ return 'sorry_may2013';
+ }
+
+ function getTemplateDir() {
+ return __DIR__ . "/templates";
+ }
+}
diff --git
a/sites/all/modules/oneoffs/201305_paypal_recurring/sorry_may2013_paypal_recurring.php
b/sites/all/modules/oneoffs/201305_paypal_recurring/sorry_may2013_paypal_recurring.php
new file mode 100644
index 0000000..d53c337
--- /dev/null
+++
b/sites/all/modules/oneoffs/201305_paypal_recurring/sorry_may2013_paypal_recurring.php
@@ -0,0 +1,63 @@
+<?php
+
+use wmf_communication\Job;
+use wmf_communication\Recipient;
+
+/**
+ * Create a mailing job to apologize for the May 2013 Paypal recurring hole.
+ *
+ * See https://mingle.corp.wikimedia.org/projects/fundraiser_2012/cards/986
+ */
+function sorry_may2013_paypal_recurring_build_job() {
+ $dbs = module_invoke( 'wmf_civicrm', 'get_dbs' );
+
+ $dbs->push( 'civicrm' );
+ $result = db_query( "
+SELECT
+ cc.id AS contribution_id,
+ cc.total_amount AS amount,
+ cc.receive_date,
+ cc.contact_id,
+ ce.email
+FROM civicrm_contribution cc
+LEFT JOIN civicrm_email ce ON ce.contact_id = cc.contact_id
+LEFT JOIN civicrm_address ca ON ca.contact_id = cc.contact_id
+LEFT JOIN civicrm_country cco ON ca.country_id = cco.id
+WHERE
+ cc.thankyou_date IS NULL
+ AND cc.trxn_id LIKE 'RECURRING PAYPAL%'
+ AND cco.iso_code = 'US'
+ AND cc.receive_date BETWEEN '2013-02-01' AND '2013-05-01'
+ AND ce.is_primary
+GROUP BY
+ cc.id
+;
+" );
+ $contributions = $result->fetchAllAssoc( 'contribution_id',
PDO::FETCH_ASSOC );
+
+ if ( !$contributions ) {
+ drush_print( "No matching records found! Aborting." );
+ return;
+ }
+
+ $byContact = array();
+ foreach ( $contributions as $row ) {
+ $byContact[$row['email']][] = $row;
+ }
+
+ $dbs->push( 'default' );
+
+ $job = Job::create( 'SorryRecurringTemplate' );
+
+ foreach ( $byContact as $contactId => $contributions ) {
+ Recipient::create(
+ $job->getId(),
+ $contactId,
+ array(
+ 'contributions' => $contributions,
+ )
+ );
+ }
+
+ drush_print( "Built mailing job. Run using 'drush mail-job
{$job->getId()}'" );
+}
diff --git a/sites/all/modules/oneoffs/oneoffs.drush.inc
b/sites/all/modules/oneoffs/oneoffs.drush.inc
new file mode 100644
index 0000000..3b0170f
--- /dev/null
+++ b/sites/all/modules/oneoffs/oneoffs.drush.inc
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Create a mailing job to apologize for the May 2013 Paypal recurring hole.
+ *
+ * See https://mingle.corp.wikimedia.org/projects/fundraiser_2012/cards/986
+ */
+function oneoffs_drush_command() {
+ $items = array(
+ 'oneoffs-sorry-may2013-build-job' => array(
+ 'description' => 'Compile a list of people affected',
+ ),
+ );
+
+ return $items;
+}
+
+function drush_oneoffs_sorry_may2013_build_job() {
+ require_once '201305_paypal_recurring/sorry_may2013_paypal_recurring.php';
+ sorry_may2013_paypal_recurring_build_job();
+}
diff --git a/sites/all/modules/oneoffs/oneoffs.info
b/sites/all/modules/oneoffs/oneoffs.info
new file mode 100755
index 0000000..053a79e
--- /dev/null
+++ b/sites/all/modules/oneoffs/oneoffs.info
@@ -0,0 +1,6 @@
+name = WMF One-offs
+description = Single-use scripts which need to run in the Drupal scope
+core = 7.x
+package = Wikimedia
+dependencies[] = wmf_communication
+files[] = 201305_paypal_recurring/SorryRecurringTemplate.php
diff --git a/sites/all/modules/oneoffs/oneoffs.module
b/sites/all/modules/oneoffs/oneoffs.module
new file mode 100644
index 0000000..b3d9bbc
--- /dev/null
+++ b/sites/all/modules/oneoffs/oneoffs.module
@@ -0,0 +1 @@
+<?php
--
To view, visit https://gerrit.wikimedia.org/r/74573
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic9ce7d36eeee0f9bbcbbdab65a578dd9f10d6b2c
Gerrit-PatchSet: 5
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>
Gerrit-Reviewer: Katie Horn <[email protected]>
Gerrit-Reviewer: Mwalker <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits