diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2018-07-19 05:03:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-19 05:03:16 +0300 |
commit | 2020b122615789c36eaa0917e10b483f12793b3c (patch) | |
tree | cf81d97d51b825a2b941d7766f93b38ff7e4bb1c /plugins/Goals | |
parent | 105e007721b5c0ea12ff2596d8d82c721021fb4e (diff) |
Add ability for Archivers to initiate archiving for other plugins & use in Goals (#13105)
* Add required segments for Goals.get to known segments to archive list.
* Add test to ArchiveCronTest.
* Allow archiving dependent archives in Goals Archiver.
* Clean up last commit & use Segment::combine in more places.
* skip dependent processing if same plugin/segment
* Move ArchiveCronTest to CoreConsole plugin since it is rather long running.
* Fixing tests.
* Remove use statements.
* Fix tests dependent on archive tables.
* check w/ urlencoded/decoded segment/condition in Segment::combine().
* Another test fix
* final test fix
Diffstat (limited to 'plugins/Goals')
-rw-r--r-- | plugins/Goals/API.php | 17 | ||||
-rw-r--r-- | plugins/Goals/Archiver.php | 7 |
2 files changed, 11 insertions, 13 deletions
diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php index 7bd161087f..5d091aa8a4 100644 --- a/plugins/Goals/API.php +++ b/plugins/Goals/API.php @@ -23,6 +23,7 @@ use Piwik\Plugins\API\DataTable\MergeDataTables; use Piwik\Plugins\CoreHome\Columns\Metrics\ConversionRate; use Piwik\Plugins\Goals\Columns\Metrics\AverageOrderRevenue; use Piwik\Plugin\ReportsProvider; +use Piwik\Segment; use Piwik\Segment\SegmentExpression; use Piwik\Site; use Piwik\Tracker\Cache; @@ -54,6 +55,7 @@ use Piwik\Validators\WhitelistedValue; class API extends \Piwik\Plugin\API { const AVG_PRICE_VIEWED = 'avg_price_viewed'; + const NEW_VISIT_SEGMENT = 'visitorType==new'; /** * Return a single goal. @@ -410,7 +412,7 @@ class API extends \Piwik\Plugin\API $segments = array( '' => false, - '_new_visit' => 'visitorType%3D%3Dnew', // visitorType==new + '_new_visit' => self::NEW_VISIT_SEGMENT, '_returning_visit' => VisitFrequencyAPI::RETURNING_VISITOR_SEGMENT ); @@ -518,18 +520,7 @@ class API extends \Piwik\Plugin\API protected function appendSegment($segment, $segmentToAppend) { - if (empty($segment)) { - return $segmentToAppend; - } - - if (empty($segmentToAppend)) { - return $segment; - } - - $segment .= urlencode(SegmentExpression::AND_DELIMITER); - $segment .= $segmentToAppend; - - return $segment; + return Segment::combine($segment, SegmentExpression::AND_DELIMITER, $segmentToAppend); } protected function getNumeric($idSite, $period, $date, $segment, $toFetch) diff --git a/plugins/Goals/Archiver.php b/plugins/Goals/Archiver.php index b96d9b94b7..f8cdf9ab89 100644 --- a/plugins/Goals/Archiver.php +++ b/plugins/Goals/Archiver.php @@ -14,6 +14,7 @@ use Piwik\DataArray; use Piwik\DataTable; use Piwik\Metrics; use Piwik\Tracker\GoalManager; +use Piwik\Plugins\VisitFrequency\API as VisitFrequencyAPI; class Archiver extends \Piwik\Plugin\Archiver { @@ -33,6 +34,9 @@ class Archiver extends \Piwik\Plugin\Archiver const LOG_CONVERSION_TABLE = 'log_conversion'; const VISITS_COUNT_FIELD = 'visitor_count_visits'; const DAYS_SINCE_FIRST_VISIT_FIELD = 'visitor_days_since_first'; + + const NEW_VISIT_SEGMENT = 'visitorType%3D%3Dnew'; // visitorType==new + /** * This array stores the ranges to use when displaying the 'visits to conversion' report */ @@ -86,6 +90,9 @@ class Archiver extends \Piwik\Plugin\Archiver { $this->aggregateGeneralGoalMetrics(); $this->aggregateEcommerceItems(); + + $this->getProcessor()->processDependentArchive('Goals', API::NEW_VISIT_SEGMENT); + $this->getProcessor()->processDependentArchive('Goals', VisitFrequencyAPI::RETURNING_VISITOR_SEGMENT); } protected function aggregateGeneralGoalMetrics() |