Awight has uploaded a new change for review.

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

Change subject: One-off script to repair payment audit import
......................................................................

One-off script to repair payment audit import

The data is actually damaged for all audit imports, but the job covered here
is important cos the listener was off for some of this time.

Bug: T113087
Change-Id: Icc00a64d0db1b8f3f4ca7cf7246808474e8f97bc
---
A sites/all/modules/oneoffs/201509_paypal_audit/delete.sql
A sites/all/modules/oneoffs/201509_paypal_audit/relink.sql
2 files changed, 19 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/16/239516/1

diff --git a/sites/all/modules/oneoffs/201509_paypal_audit/delete.sql 
b/sites/all/modules/oneoffs/201509_paypal_audit/delete.sql
new file mode 100644
index 0000000..b4fc02a
--- /dev/null
+++ b/sites/all/modules/oneoffs/201509_paypal_audit/delete.sql
@@ -0,0 +1,12 @@
+-- Need to delete the empty records before repairing associations, due to the
+-- unique constraint on t.contribution_id.
+delete from drupal.contribution_tracking t
+join civicrm_contribution c
+       on c.id=t.contribution_id
+join wmf_contribution_extra e
+       on e.entity_id = c.id
+where
+       e.gateway = 'paypal'
+       -- This seems to be unique enough
+       and e.source_run_id = '19074'
+       and e.source_version = '3e0e3ae799a507b378d0ece3e71631b10b361329';
diff --git a/sites/all/modules/oneoffs/201509_paypal_audit/relink.sql 
b/sites/all/modules/oneoffs/201509_paypal_audit/relink.sql
new file mode 100644
index 0000000..52888b5
--- /dev/null
+++ b/sites/all/modules/oneoffs/201509_paypal_audit/relink.sql
@@ -0,0 +1,7 @@
+-- Build by plugging the follow code into the audit parser's send method, and
+-- running over all TRR files from 20150828 through 20150918
+--
+-- if msg['contribution_tracking_id'] and msg['gateway_txn_id']:
+--     print "update drupal.contribution_tracking t set contribution_id = 
(select id from civicrm_contribution where trxn_id = 'PAYPAL " + 
msg['gateway_txn_id'] + "') where t.id = " + msg['contribution_tracking_id'] + 
";"
+
+

-- 
To view, visit https://gerrit.wikimedia.org/r/239516
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc00a64d0db1b8f3f4ca7cf7246808474e8f97bc
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to