Ejegg has uploaded a new change for review.

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

Change subject: Mirror messages to new queues in GC audit
......................................................................

Mirror messages to new queues in GC audit

When the SmashPig config has verified-new and refund-new config keys,
the GC audit parser will send copies of queue messages there.

Could have done this with a MultiQueueWriter, but that would have
mutated the source fields and required transforming the body into
a DonationInterfaceMessage. This seems like the smallest code change
that will accomplish the needful.

Bug: T141484
Change-Id: I25ef9c8193276421c933c26eaf68e06003ae9982
---
M sites/all/modules/globalcollect_audit/globalcollect_audit.drush.inc
M sites/all/modules/globalcollect_audit/globalcollect_audit.module
2 files changed, 23 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/74/305674/1

diff --git 
a/sites/all/modules/globalcollect_audit/globalcollect_audit.drush.inc 
b/sites/all/modules/globalcollect_audit/globalcollect_audit.drush.inc
index a2e6947..0f02c6f 100644
--- a/sites/all/modules/globalcollect_audit/globalcollect_audit.drush.inc
+++ b/sites/all/modules/globalcollect_audit/globalcollect_audit.drush.inc
@@ -7,6 +7,9 @@
  * @TODO print some useful info to STDOUT
  */
 
+use SmashPig\Core\Context;
+use SmashPig\Core\Configuration;
+
 /**
  * Implementation of hook_drush_command()
  */
@@ -69,6 +72,9 @@
  * TODO: More comments here-ish. 
  */
 function drush_globalcollect_audit() {
+       $config = new Configuration();
+       Context::initWithLogger( $config, 'globalcollect_audit' );
+
        //$args = drush_get_arguments();
        
        //if the last execution died before we got back here
diff --git a/sites/all/modules/globalcollect_audit/globalcollect_audit.module 
b/sites/all/modules/globalcollect_audit/globalcollect_audit.module
index 7e28d98..3e25a94 100644
--- a/sites/all/modules/globalcollect_audit/globalcollect_audit.module
+++ b/sites/all/modules/globalcollect_audit/globalcollect_audit.module
@@ -1,4 +1,6 @@
-<?php 
+<?php
+use SmashPig\Core\Configuration;
+use SmashPig\Core\ConfigurationKeyException;
 
 define( 'GC_AUDIT_WR1_PARSER_DIR', '/usr/local/src/Wr1Parser/' );
 define( 'GC_AUDIT_WR1_FILES_DIR', '/usr/local/src/Wr1_files/' );
@@ -350,7 +352,7 @@
                                $local_found_ids[] = $order_id;
                                globalcollect_audit_echo('!');
                        } else {
-                               if ( globalcollect_audit_send_stomp( 
'donations', $missing_txn_message ) ){
+                               if ( globalcollect_audit_send_queue_message( 
'donations', $missing_txn_message ) ){
                                        watchdog('globalcollect_audit', 
__FUNCTION__ . ': Message sent to stomp successfully: ' . print_r( 
$missing_txn_message, true ), array(), WATCHDOG_INFO);
                                        $local_found_ids[] = $order_id;
                                        globalcollect_audit_echo('!');
@@ -393,7 +395,7 @@
                                $local_built_ids[] = $order_id;
                                globalcollect_audit_echo('!');
                        } else {
-                               if ( globalcollect_audit_send_stomp( 
'donations', $missing_txn_message ) ){
+                               if ( globalcollect_audit_send_queue_message( 
'donations', $missing_txn_message ) ){
                                        watchdog('globalcollect_audit', 
__FUNCTION__ . ': Message sent to stomp successfully: ' . print_r( 
$missing_txn_message, true ), array(), WATCHDOG_INFO);
                                        $local_built_ids[] = $order_id;
                                        globalcollect_audit_echo('!');
@@ -650,8 +652,6 @@
                'optout' => array( 'contribution_tracking', 'optout' ),
                'anonymous' => array( 'contribution_tracking', 'anonymous' ),
                'comment' => array( 'contribution_tracking', 'note' ), //I 
think.
-               'size',
-               'premium_language',
                'utm_source' => array( 'contribution_tracking', 'utm_source' ),
                'utm_medium' => array( 'contribution_tracking', 'utm_medium' ),
                'utm_campaign' => array( 'contribution_tracking', 
'utm_campaign' ),
@@ -667,6 +667,7 @@
                'country' => array( 'donor_data', 'COUNTRYCODE' ),
                'postal_code' => array( 'donor_data', 'ZIP' ),
                'gateway_txn_id' => array( 'donor_data', 'ORDERID' ),
+               'order_id' => array( 'donor_data', 'ORDERID' ), //fixme: should 
be merchant reference
                'response', //? Maybe some dummy value for "found it in the 
audit phase"
                'currency' => array( 'donor_data', 'CURRENCYCODE' ),
                'date' => array( 'contribution_tracking', 'ts' ), 
//double-check how the dates work
@@ -1046,7 +1047,7 @@
                                'type' => wr1_get_negative_type( $wr1 ), 
//refund or chargeback
                        );
                        echo print_r( $send_message, true );
-                       globalcollect_audit_send_stomp( 'refund', $send_message 
);
+                       globalcollect_audit_send_queue_message( 'refund', 
$send_message );
                        $count += 1;
                        globalcollect_audit_echo( '.' );
                        unset( $missing[$index] ); //only unset if we killed it
@@ -2007,7 +2008,7 @@
        }
 }
 
-function globalcollect_audit_send_stomp( $queueId, $body ) {
+function globalcollect_audit_send_queue_message( $queueId, $body ) {
     static $q;
 
     if ( !$q ) {
@@ -2017,15 +2018,24 @@
     // FIXME: register the queue mapping somewhere sane
     if ( $queueId === 'donations' ) {
         $queuePath = variable_get( 'queue2civicrm_subscription', 
'/queue/donations' );
+               $configKey = 'data-store/verified-new';
     } elseif ( $queueId === 'refund' ) {
         $queuePath = variable_get( 'refund_queue', '/queue/refund' );
+               $configKey = 'data-store/refund-new';
     } else {
         throw new Exception( "What kind of a queue is this??: {$queueId}" );
     }
 
     $headers = array();
     wmf_common_set_message_source( $headers, 'audit', 'GlobalCollect WR1 
Auditor' );
+       wmf_common_set_message_source( $body, 'audit', 'GlobalCollect WR1 
Auditor' );
 
+       try {
+               $newQueue = Configuration::getDefaultConfig()->object( 
$configKey, true );
+               $newQueue->push( $body );
+       } catch ( ConfigurationKeyException $ex ) {
+               // do nothing
+       }
     return $q->enqueue( json_encode( $body ), $headers, $queuePath );
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I25ef9c8193276421c933c26eaf68e06003ae9982
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to