diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-06-07 04:20:34 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-06-07 04:20:34 +0400 |
commit | a701d4a43a7185b9d9422de0d1d97c9b2e0fcc5d (patch) | |
tree | afc6cc4ae2bd371fa57c692c828a2e45dc3741d7 /plugins/VisitorInterest/Archiver.php | |
parent | 3fe760eaf2c811978f1ca6ba8056c50983a40f99 (diff) |
Killing the Archiver from VisitFrequency. Nice! using VisitsSummary.get API instead, with a visitorType==returning segment
Fixing a 4 year old bug which I'm happy about!
Also removing an old hack in Archive.php
Diffstat (limited to 'plugins/VisitorInterest/Archiver.php')
-rw-r--r-- | plugins/VisitorInterest/Archiver.php | 69 |
1 files changed, 24 insertions, 45 deletions
diff --git a/plugins/VisitorInterest/Archiver.php b/plugins/VisitorInterest/Archiver.php index 8008671d9b..59e7e348c1 100644 --- a/plugins/VisitorInterest/Archiver.php +++ b/plugins/VisitorInterest/Archiver.php @@ -12,6 +12,10 @@ class Piwik_VisitorInterest_Archiver extends Piwik_PluginsArchiver { // third element is unit (s for seconds, default is munutes) + const TIME_SPENT_RECORD_NAME = 'VisitorInterest_timeGap'; + const PAGES_VIEWED_RECORD_NAME = 'VisitorInterest_pageGap'; + const BY_VISIT_COUNT_RECORD_NAME = 'VisitorInterest_visitsByVisitCount'; + const DAYS_SINCE_LAST_RECORD_NAME = 'VisitorInterest_daysSinceLastVisit'; protected static $timeGap = array( array(0, 10, 's'), array(11, 30, 's'), @@ -24,7 +28,6 @@ class Piwik_VisitorInterest_Archiver extends Piwik_PluginsArchiver array(15, 30), array(30) ); - protected static $pageGap = array( array(1, 1), array(2, 2), @@ -37,7 +40,6 @@ class Piwik_VisitorInterest_Archiver extends Piwik_PluginsArchiver array(15, 20), array(20) ); - /** * The set of ranges used when calculating the 'visitors who visited at least N times' report. */ @@ -57,7 +59,6 @@ class Piwik_VisitorInterest_Archiver extends Piwik_PluginsArchiver array(101, 200), array(200) ); - /** * The set of ranges used when calculating the 'days since last visit' report. */ @@ -80,7 +81,7 @@ class Piwik_VisitorInterest_Archiver extends Piwik_PluginsArchiver public function archiveDay() { -// these prefixes are prepended to the 'SELECT as' parts of each SELECT expression. detecting + // these prefixes are prepended to the 'SELECT as' parts of each SELECT expression. detecting // these prefixes allows us to get all the data in one query. $timeGapPrefix = 'tg'; $pageGapPrefix = 'pg'; @@ -113,34 +114,19 @@ class Piwik_VisitorInterest_Archiver extends Piwik_PluginsArchiver // select data for every report $row = $this->getProcessor()->queryVisitsSimple(implode(',', $selects)); - // archive visits by total time report - $recordName = 'VisitorInterest_timeGap'; - $this->archiveRangeStats($recordName, $row, Piwik_Archive::INDEX_NB_VISITS, $timeGapPrefix); - - // archive visits by total actions report - $recordName = 'VisitorInterest_pageGap'; - $this->archiveRangeStats($recordName, $row, Piwik_Archive::INDEX_NB_VISITS, $pageGapPrefix); - - // archive visits by visit number report - $recordName = 'VisitorInterest_visitsByVisitCount'; - $this->archiveRangeStats($recordName, $row, Piwik_Archive::INDEX_NB_VISITS, $visitsByVisitNumPrefix); - - // archive days since last visit report - $recordName = 'VisitorInterest_daysSinceLastVisit'; - $this->archiveRangeStats($recordName, $row, Piwik_Archive::INDEX_NB_VISITS, $daysSinceLastVisitPrefix); - } - - public function archivePeriod() - { - $dataTableToSum = array( - 'VisitorInterest_timeGap', - 'VisitorInterest_pageGap', - 'VisitorInterest_visitsByVisitCount', - 'VisitorInterest_daysSinceLastVisit' + $prefixes = array( + self::TIME_SPENT_RECORD_NAME => $timeGapPrefix, + self::PAGES_VIEWED_RECORD_NAME => $pageGapPrefix, + self::BY_VISIT_COUNT_RECORD_NAME => $visitsByVisitNumPrefix, + self::DAYS_SINCE_LAST_RECORD_NAME => $daysSinceLastVisitPrefix, ); - $this->getProcessor()->archiveDataTable($dataTableToSum); - } + foreach($prefixes as $recordName => $selectAsPrefix) { + $processor = $this->getProcessor(); + $dataTable = $processor->getSimpleDataTableFromRow($row, Piwik_Archive::INDEX_NB_VISITS, $selectAsPrefix); + $processor->insertBlobRecord($recordName, $dataTable->getSerialized()); + } + } /** * Transforms and returns the set of ranges used to calculate the 'visits by total time' @@ -162,21 +148,14 @@ class Piwik_VisitorInterest_Archiver extends Piwik_PluginsArchiver return $secondsGap; } - /** - * Creates and archives a DataTable from some (or all) elements of a supplied database - * row. - * - * @param string $recordName The record name to use when inserting the new archive. - * @param array $row The database row to use. - * @param string $selectAsPrefix The string to look for as the prefix of SELECT as - * expressions. Elements in $row that have a SELECT as - * with this string as a prefix are used in creating - * the DataTable.' - */ - protected function archiveRangeStats($recordName, $row, $index, $selectAsPrefix) + public function archivePeriod() { - $dataTable = $this->getProcessor()->getSimpleDataTableFromRow($row, $index, $selectAsPrefix); - - $this->getProcessor()->insertBlobRecord($recordName, $dataTable->getSerialized()); + $dataTableToSum = array( + self::TIME_SPENT_RECORD_NAME, + self::PAGES_VIEWED_RECORD_NAME, + self::BY_VISIT_COUNT_RECORD_NAME, + self::DAYS_SINCE_LAST_RECORD_NAME + ); + $this->getProcessor()->archiveDataTable($dataTableToSum); } }
\ No newline at end of file |