diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-11-01 05:31:16 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-11-01 05:31:16 +0400 |
commit | fd41dccadb6eaf07e1aff4e41153d87423b525d6 (patch) | |
tree | 3fdf39a427b2933e4649abd3713bcfa934892c1b /plugins/Actions/Archiver.php | |
parent | 3ecc6f3be0a5c77a85b475f65d031e21f87bbe4b (diff) |
Minor
Diffstat (limited to 'plugins/Actions/Archiver.php')
-rw-r--r-- | plugins/Actions/Archiver.php | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/plugins/Actions/Archiver.php b/plugins/Actions/Archiver.php index 680402c2e8..862e5d496c 100644 --- a/plugins/Actions/Archiver.php +++ b/plugins/Actions/Archiver.php @@ -130,6 +130,34 @@ class Archiver extends \Piwik\Plugin\Archiver } /** + * @param $select + * @param $from + */ + protected function updateQuerySelectFromForSiteSearch(&$select, &$from) + { + $selectFlagNoResultKeywords = ", + CASE WHEN (MAX(log_link_visit_action.custom_var_v" . ActionSiteSearch::CVAR_INDEX_SEARCH_COUNT . ") = 0 + AND log_link_visit_action.custom_var_k" . ActionSiteSearch::CVAR_INDEX_SEARCH_COUNT . " = '" . ActionSiteSearch::CVAR_KEY_SEARCH_COUNT . "') + THEN 1 ELSE 0 END + AS `" . Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT . "`"; + + //we need an extra JOIN to know whether the referrer "idaction_name_ref" was a Site Search request + $from[] = array( + "table" => "log_action", + "tableAlias" => "log_action_name_ref", + "joinOn" => "log_link_visit_action.idaction_name_ref = log_action_name_ref.idaction" + ); + + $selectPageIsFollowingSiteSearch = ", + SUM( CASE WHEN log_action_name_ref.type = " . Action::TYPE_SITE_SEARCH . " + THEN 1 ELSE 0 END) + AS `" . Metrics::INDEX_PAGE_IS_FOLLOWING_SITE_SEARCH_NB_HITS . "`"; + + $select .= $selectFlagNoResultKeywords + . $selectPageIsFollowingSiteSearch; + } + + /** * Initializes the DataTables created by the archiveDay function. */ private function initActionsTables() @@ -216,26 +244,7 @@ class Archiver extends \Piwik\Plugin\Archiver // 1) No result Keywords // 2) For each page view, count number of times the referrer page was a Site Search if ($this->isSiteSearchEnabled()) { - $selectFlagNoResultKeywords = ", - CASE WHEN (MAX(log_link_visit_action.custom_var_v" . ActionSiteSearch::CVAR_INDEX_SEARCH_COUNT . ") = 0 - AND log_link_visit_action.custom_var_k" . ActionSiteSearch::CVAR_INDEX_SEARCH_COUNT . " = '" . ActionSiteSearch::CVAR_KEY_SEARCH_COUNT . "') - THEN 1 ELSE 0 END - AS `" . Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT . "`"; - - //we need an extra JOIN to know whether the referrer "idaction_name_ref" was a Site Search request - $from[] = array( - "table" => "log_action", - "tableAlias" => "log_action_name_ref", - "joinOn" => "log_link_visit_action.idaction_name_ref = log_action_name_ref.idaction" - ); - - $selectPageIsFollowingSiteSearch = ", - SUM( CASE WHEN log_action_name_ref.type = " . Action::TYPE_SITE_SEARCH. " - THEN 1 ELSE 0 END) - AS `" . Metrics::INDEX_PAGE_IS_FOLLOWING_SITE_SEARCH_NB_HITS . "`"; - - $select .= $selectFlagNoResultKeywords - . $selectPageIsFollowingSiteSearch; + $this->updateQuerySelectFromForSiteSearch($select, $from); } $this->archiveDayQueryProcess($select, $from, $where, $orderBy, $groupBy, "idaction_name", $rankingQuery); |