jenkins-bot has submitted this change and it was merged.

Change subject: Allow passing a date to WD dumpDownloads
......................................................................


Allow passing a date to WD dumpDownloads

Change-Id: Ie3a03cd8dd77aadac5ec24ee0ddfaeb82a7596ad
---
M src/wikidata/dumpDownloads.php
1 file changed, 15 insertions(+), 7 deletions(-)

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



diff --git a/src/wikidata/dumpDownloads.php b/src/wikidata/dumpDownloads.php
index 5a935a2..2724970 100755
--- a/src/wikidata/dumpDownloads.php
+++ b/src/wikidata/dumpDownloads.php
@@ -43,17 +43,25 @@
                'wikidatawiki-[0-9]{8}-pages-meta-hist-incr.xml\.(gz|bz2)',
 );
 
-// We will get data for 3 days ago. To do this we need the logs from 3 and 2 
days ago.
-$targetDate = date('d/M/Y', strtotime('-3 days', time()));// For format 
[01/Jul/2016:
-$graphiteDate = date('Y-m-d', strtotime('-3 days', time()));// Date formatted 
for graphite
-$twoDaysAgo = date('Ymd', strtotime('-2 days', time()));
-$threeDaysAgo = date('Ymd', strtotime('-3 days', time()));
+// Optionally take a date passed into the script
+if ( array_key_exists( 1, $argv ) ) {
+       $targetTime = strtotime( $argv[1] );
+} else {
+       $targetTime = strtotime( '-4 days', time() );
+}
+
+$targetDate = date( 'd/M/Y', $targetTime );// For format [01/Jul/2016:
+$graphiteDate = date( 'Y-m-d', $targetTime );// Date formatted for graphite
+$fileFormatDayAfter = date( 'Ymd', strtotime( '+1 days', $targetTime ) );
+$fileFormatTargetDate = date( 'Ymd', $targetTime );
 
 $logFiles = array(
-       $logDirectory . DIRECTORY_SEPARATOR . 'access.log-' . $twoDaysAgo . 
'.gz',
-       $logDirectory . DIRECTORY_SEPARATOR . 'access.log-' . $threeDaysAgo . 
'.gz',
+       $logDirectory . DIRECTORY_SEPARATOR . 'access.log-' . 
$fileFormatDayAfter . '.gz',
+       $logDirectory . DIRECTORY_SEPARATOR . 'access.log-' . 
$fileFormatTargetDate . '.gz',
 );
 
+$output->outputMessage( 'Targeting date: ' . $targetDate );
+
 $counters = array();
 foreach( $logFiles as $logFile ) {
        $handle = fopen( 'compress.zlib://' . $logFile, 'r' );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie3a03cd8dd77aadac5ec24ee0ddfaeb82a7596ad
Gerrit-PatchSet: 3
Gerrit-Project: analytics/wmde/scripts
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to