diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-01-29 06:48:23 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-02-13 08:23:10 +0300 |
commit | 8ef47c8e4a3fb0094b4b0c19df8ed18c58cf7a6f (patch) | |
tree | 162315afc7f5a5bc0c8840eff30251a76b665b6f /plugins/VisitTime | |
parent | ec8dc0f150d71b752188dac3d01d29950ae6f869 (diff) |
refs #4633 open segmented visitor log with one click on a row
Diffstat (limited to 'plugins/VisitTime')
-rw-r--r-- | plugins/VisitTime/API.php | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/plugins/VisitTime/API.php b/plugins/VisitTime/API.php index f27e5f812a..d0a52b2a45 100644 --- a/plugins/VisitTime/API.php +++ b/plugins/VisitTime/API.php @@ -14,6 +14,7 @@ use Piwik\DataTable; use Piwik\Date; use Piwik\Metrics; use Piwik\Period; +use Piwik\Period\Range; use Piwik\Piwik; use Piwik\Site; @@ -31,6 +32,7 @@ class API extends \Piwik\Plugin\API Piwik::checkUserHasViewAccess($idSite); $archive = Archive::build($idSite, $period, $date, $segment); $dataTable = $archive->getDataTable($name); + $dataTable->filter('Sort', array('label', 'asc', true)); $dataTable->queueFilter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getTimeLabel')); $dataTable->queueFilter('ReplaceColumnNames'); @@ -39,12 +41,35 @@ class API extends \Piwik\Plugin\API public function getVisitInformationPerLocalTime($idSite, $period, $date, $segment = false) { - return $this->getDataTable(Archiver::LOCAL_TIME_RECORD_NAME, $idSite, $period, $date, $segment); + $table = $this->getDataTable(Archiver::LOCAL_TIME_RECORD_NAME, $idSite, $period, $date, $segment); + $table->filter('AddSegmentValue'); + + return $table; } public function getVisitInformationPerServerTime($idSite, $period, $date, $segment = false, $hideFutureHoursWhenToday = false) { $table = $this->getDataTable(Archiver::SERVER_TIME_RECORD_NAME, $idSite, $period, $date, $segment); + + $timezone = Site::getTimezoneFor($idSite); + + $range = Range::parseDateRange($date); + if (!empty($range[2])) { + $endDate = Date::factory($range[2]); + } else { + $endDate = Date::factory($date); + } + + $table->filter('AddSegmentValue', array(function ($label) use ($timezone, $endDate) { + $hour = str_pad($label, 2, 0, STR_PAD_LEFT); + $time = $hour . ':00:00'; + + $dateInTimezone = $endDate->setTime($time)->setTimezone($timezone); + $hourInTz = $dateInTimezone->getHourInUTC(); + + return $hourInTz; + })); + if ($hideFutureHoursWhenToday) { $table = $this->removeHoursInFuture($table, $idSite, $period, $date); } |