Addshore has uploaded a new change for review.

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

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, 14 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/analytics/wmde/scripts 
refs/changes/84/303784/1

diff --git a/src/wikidata/dumpDownloads.php b/src/wikidata/dumpDownloads.php
index 5a935a2..9ff7bb4 100755
--- a/src/wikidata/dumpDownloads.php
+++ b/src/wikidata/dumpDownloads.php
@@ -43,15 +43,22 @@
                '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 = new DateTime( $argv[1] );
+       $targetTime = $targetTime->getTimestamp();
+} 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',
 );
 
 $counters = array();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie3a03cd8dd77aadac5ec24ee0ddfaeb82a7596ad
Gerrit-PatchSet: 1
Gerrit-Project: analytics/wmde/scripts
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>

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

Reply via email to