Katie Horn has submitted this change and it was merged.

Change subject: Parse datestamp in both WorldPay audit file formats
......................................................................


Parse datestamp in both WorldPay audit file formats

Change-Id: Icf12186ae85fa5e003328c15a655bdd57f3f1336
---
M sites/all/modules/wmf_audit/worldpay/worldpay_audit.module
1 file changed, 20 insertions(+), 7 deletions(-)

Approvals:
  Katie Horn: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/sites/all/modules/wmf_audit/worldpay/worldpay_audit.module 
b/sites/all/modules/wmf_audit/worldpay/worldpay_audit.module
index efb9f26..a4d09bb 100644
--- a/sites/all/modules/wmf_audit/worldpay/worldpay_audit.module
+++ b/sites/all/modules/wmf_audit/worldpay/worldpay_audit.module
@@ -141,13 +141,26 @@
  * @return string date in YYYYMMDD format
  */
 function worldpay_audit_get_recon_file_date( $file ){
-  //WP recon files look like the following thing:
-  //  MA.PISCESSW.#M.RECON.WIKI.D280514
-  //For that, we'd want to return 20140518
-  $parts = explode('.', $file);
-  $end_piece = $parts[count($parts)-1];
-  $date = '20' . substr( $end_piece, 5, 2) . substr( $end_piece, 3, 2) . 
substr( $end_piece, 1, 2);
-  return $date;
+  // FIXME: this is two-fer-one functionality.  Unmash.
+
+  if ( preg_match( '/\.RECON\.WIKI\./', $file ) ) {
+      //WP recon files look like the following thing:
+      //  MA.PISCESSW.#M.RECON.WIKI.D280514
+      //For that, we'd want to return 20140518
+      $parts = explode('.', $file);
+      $end_piece = $parts[count($parts)-1];
+      $date = '20' . substr( $end_piece, 5, 2) . substr( $end_piece, 3, 2) . 
substr( $end_piece, 1, 2);
+      return $date;
+  } elseif ( preg_match( '/TranDetVer2/', $file ) ) {
+      // These files have the equally crazy format:
+      //   TranDetVer2_60879_6-21-2014_8'27'38 AM.csv
+      $parts = explode( '_', $file );
+      $dateStr = $parts[2];
+      $dateParts = explode( '-', $dateStr );
+      $date = $dateParts[2] . str_pad( $dateParts[0], 2, '0' ) . str_pad( 
$dateParts[1], 2, '0' );
+      return $date;
+  }
+  throw new Exception( "Cannot parse date in surprise file {$file}" );
 }
 
 /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Icf12186ae85fa5e003328c15a655bdd57f3f1336
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Katie Horn <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to