Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/VisitTime/VisitTime.php')
-rw-r--r--plugins/VisitTime/VisitTime.php95
1 files changed, 12 insertions, 83 deletions
diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php
index 5b05342bed..b74a48f59e 100644
--- a/plugins/VisitTime/VisitTime.php
+++ b/plugins/VisitTime/VisitTime.php
@@ -114,7 +114,7 @@ class Piwik_VisitTime extends Piwik_Plugin
$acceptedValues = "0, 1, 2, 3, ..., 20, 21, 22, 23";
$segments[] = array(
'type' => 'dimension',
- 'category' => 'Visit',
+ 'category' => Piwik_Translate('General_Visit'),
'name' => Piwik_Translate('VisitTime_ColumnServerTime'),
'segment' => 'visitServerHour',
'sqlSegment' => 'HOUR(log_visit.visit_last_action_time)',
@@ -122,7 +122,7 @@ class Piwik_VisitTime extends Piwik_Plugin
);
$segments[] = array(
'type' => 'dimension',
- 'category' => 'Visit',
+ 'category' => Piwik_Translate('General_Visit'),
'name' => Piwik_Translate('VisitTime_ColumnLocalTime'),
'segment' => 'visitLocalHour',
'sqlSegment' => 'HOUR(log_visit.visitor_localtime)',
@@ -130,96 +130,25 @@ class Piwik_VisitTime extends Piwik_Plugin
);
}
- /**
- * @param Piwik_Event_Notification $notification notification object
- * @return mixed
- */
function archivePeriod($notification)
{
- $archiveProcessing = $notification->getNotificationObject();
-
- if (!$archiveProcessing->shouldProcessReportsForPlugin($this->getPluginName())) return;
-
- $dataTableToSum = array(
- 'VisitTime_localTime',
- 'VisitTime_serverTime',
- );
- $archiveProcessing->archiveDataTable($dataTableToSum);
- }
-
- /**
- * @param Piwik_Event_Notification $notification notification object
- * @return mixed
- */
- public function archiveDay($notification)
- {
- $archiveProcessing = $notification->getNotificationObject();
-
- if (!$archiveProcessing->shouldProcessReportsForPlugin($this->getPluginName())) return;
-
- $this->archiveDayAggregateVisits($archiveProcessing);
- $this->archiveDayAggregateGoals($archiveProcessing);
- $this->archiveDayRecordInDatabase($archiveProcessing);
- }
-
- protected function archiveDayAggregateVisits($archiveProcessing)
- {
- $labelSQL = "HOUR(log_visit.visitor_localtime)";
- $this->interestByLocalTime = $archiveProcessing->getArrayInterestForLabel($labelSQL);
-
- $labelSQL = "HOUR(log_visit.visit_last_action_time)";
- $this->interestByServerTime = $archiveProcessing->getArrayInterestForLabel($labelSQL);
- }
-
- protected function convertServerTimeToLocalTimezone($interestByServerTime, $archiveProcessing)
- {
- $date = Piwik_Date::factory($archiveProcessing->getStartDatetimeUTC())->toString();
- $timezone = $archiveProcessing->site->getTimezone();
- $visitsByHourTz = array();
- foreach ($interestByServerTime as $hour => $stats) {
- $datetime = $date . ' ' . $hour . ':00:00';
- $hourInTz = (int)Piwik_Date::factory($datetime, $timezone)->toString('H');
- $visitsByHourTz[$hourInTz] = $stats;
- }
- return $visitsByHourTz;
- }
-
- protected function archiveDayAggregateGoals($archiveProcessing)
- {
- $query = $archiveProcessing->queryConversionsByDimension("HOUR(log_conversion.server_time)");
+ $archiveProcessor = $notification->getNotificationObject();
- if ($query === false) return;
-
- while ($row = $query->fetch()) {
- if (!isset($this->interestByServerTime[$row['label']][Piwik_Archive::INDEX_GOALS][$row['idgoal']])) $this->interestByServerTime[$row['label']][Piwik_Archive::INDEX_GOALS][$row['idgoal']] = $archiveProcessing->getNewGoalRow($row['idgoal']);
- $archiveProcessing->updateGoalStats($row, $this->interestByServerTime[$row['label']][Piwik_Archive::INDEX_GOALS][$row['idgoal']]);
+ $archiving = new Piwik_VisitTime_Archiver($archiveProcessor);
+ if($archiving->shouldArchive()) {
+ $archiving->archivePeriod();
}
- $goalByServerTime = $this->convertServerTimeToLocalTimezone($this->interestByServerTime, $archiveProcessing);
- $archiveProcessing->enrichConversionsByLabelArray($this->interestByServerTime);
}
- protected function archiveDayRecordInDatabase($archiveProcessing)
- {
- $tableLocalTime = $archiveProcessing->getDataTableFromArray($this->interestByLocalTime);
- $this->makeSureAllHoursAreSet($tableLocalTime, $archiveProcessing);
- $archiveProcessing->insertBlobRecord('VisitTime_localTime', $tableLocalTime->getSerialized());
- destroy($tableLocalTime);
-
- $this->interestByServerTime = $this->convertServerTimeToLocalTimezone($this->interestByServerTime, $archiveProcessing);
- $tableServerTime = $archiveProcessing->getDataTableFromArray($this->interestByServerTime);
- $this->makeSureAllHoursAreSet($tableServerTime, $archiveProcessing);
- $archiveProcessing->insertBlobRecord('VisitTime_serverTime', $tableServerTime->getSerialized());
- destroy($tableServerTime);
- }
- private function makeSureAllHoursAreSet($table, $archiveProcessing)
+ public function archiveDay($notification)
{
- for ($i = 0; $i <= 23; $i++) {
- if ($table->getRowFromLabel($i) === false) {
- $row = $archiveProcessing->getNewInterestRowLabeled($i);
- $table->addRow($row);
- }
+ $archiveProcessor = $notification->getNotificationObject();
+ $archiving = new Piwik_VisitTime_Archiver($archiveProcessor);
+ if($archiving->shouldArchive()) {
+ $archiving->archiveDay();
}
}
+
}