Skip to content
Extraits de code Groupes Projets
Valider a57f6b6e rédigé par mattab's avatar mattab
Parcourir les fichiers

Refs #472 Making eventValue match work by only matching events actions + adding test

parent b3491bf6
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 66 ajouts et 21 suppressions
...@@ -124,7 +124,7 @@ class Archiver extends \Piwik\Plugin\Archiver ...@@ -124,7 +124,7 @@ class Archiver extends \Piwik\Plugin\Archiver
/** /**
* @return string * @return string
*/ */
protected function getWhereClauseActionIsNotEvent() static public function getWhereClauseActionIsNotEvent()
{ {
return " AND log_link_visit_action.idaction_event_category IS NULL"; return " AND log_link_visit_action.idaction_event_category IS NULL";
} }
......
...@@ -11,12 +11,11 @@ ...@@ -11,12 +11,11 @@
namespace Piwik\Plugins\Events; namespace Piwik\Plugins\Events;
use Piwik\Piwik; use Piwik\Piwik;
use Piwik\Plugin;
/** /**
* @package Events * @package Events
*/ */
class Events extends Plugin class Events extends \Piwik\Plugin
{ {
/** /**
* @see Piwik\Plugin::getListHooksRegistered * @see Piwik\Plugin::getListHooksRegistered
...@@ -56,13 +55,6 @@ class Events extends Plugin ...@@ -56,13 +55,6 @@ class Events extends Plugin
'sqlSegment' => 'log_link_visit_action.idaction_name', 'sqlSegment' => 'log_link_visit_action.idaction_name',
'sqlFilter' => $sqlFilter, 'sqlFilter' => $sqlFilter,
); );
$segments[] = array(
'type' => 'metric',
'category' => 'Events_Events',
'name' => 'Events_EventValue',
'segment' => 'eventValue',
'sqlSegment' => 'log_link_visit_action.custom_float'
);
$segments[] = array( $segments[] = array(
'type' => 'metric', 'type' => 'metric',
'category' => Piwik::translate('General_Visit'), 'category' => Piwik::translate('General_Visit'),
...@@ -71,5 +63,24 @@ class Events extends Plugin ...@@ -71,5 +63,24 @@ class Events extends Plugin
'sqlSegment' => 'log_visit.visit_total_events', 'sqlSegment' => 'log_visit.visit_total_events',
'acceptedValues' => 'To select all visits who triggered an Event, use: &segment=events>0', 'acceptedValues' => 'To select all visits who triggered an Event, use: &segment=events>0',
); );
$segments[] = array(
'type' => 'metric',
'category' => 'Events_Events',
'name' => 'Events_EventValue',
'segment' => 'eventValue',
'sqlSegment' => 'log_link_visit_action.custom_float',
'sqlFilter' => '\\Piwik\\Plugins\\Events\\Events::getSegmentEventValue'
);
}
public static function getSegmentEventValue($valueToMatch, $sqlField, $matchType, $segmentName)
{
$isNotEvent = \Piwik\Plugins\Actions\Archiver::getWhereClauseActionIsNotEvent();
$isEvent = str_replace("IS NULL", "IS NOT NULL", $isNotEvent);
return array(
'SQL' => " $sqlField $matchType ? " . $isEvent,
'bind' => $valueToMatch
);
} }
} }
...@@ -10,12 +10,10 @@ ...@@ -10,12 +10,10 @@
*/ */
namespace Piwik\Plugins\ExamplePlugin; namespace Piwik\Plugins\ExamplePlugin;
use Piwik\Plugin;
/** /**
* @package ExamplePlugin * @package ExamplePlugin
*/ */
class ExamplePlugin extends Plugin class ExamplePlugin extends \Piwik\Plugin
{ {
/** /**
* @see Piwik\Plugin::getListHooksRegistered * @see Piwik\Plugin::getListHooksRegistered
......
...@@ -10,12 +10,10 @@ ...@@ -10,12 +10,10 @@
*/ */
namespace Piwik\Plugins\ExampleVisualization; namespace Piwik\Plugins\ExampleVisualization;
use Piwik\Plugin;
/** /**
* @package ExampleVisualization * @package ExampleVisualization
*/ */
class ExampleVisualization extends Plugin class ExampleVisualization extends \Piwik\Plugin
{ {
/** /**
* @see Piwik_Plugin::getListHooksRegistered * @see Piwik_Plugin::getListHooksRegistered
......
...@@ -59,6 +59,7 @@ class Test_Piwik_Fixture_TwoVisitsWithCustomEvents extends Test_Piwik_BaseFixtur ...@@ -59,6 +59,7 @@ class Test_Piwik_Fixture_TwoVisitsWithCustomEvents extends Test_Piwik_BaseFixtur
protected function trackMusicPlaying(PiwikTracker $vis) protected function trackMusicPlaying(PiwikTracker $vis)
{ {
$vis->setUrl('http://example.org/webradio'); $vis->setUrl('http://example.org/webradio');
$vis->setGenerationTime(333);
self::checkResponse($vis->doTrackPageView('Welcome!')); self::checkResponse($vis->doTrackPageView('Welcome!'));
$this->moveTimeForward($vis, 1); $this->moveTimeForward($vis, 1);
...@@ -96,6 +97,7 @@ class Test_Piwik_Fixture_TwoVisitsWithCustomEvents extends Test_Piwik_BaseFixtur ...@@ -96,6 +97,7 @@ class Test_Piwik_Fixture_TwoVisitsWithCustomEvents extends Test_Piwik_BaseFixtur
// First a pageview so the time on page is tracked properly // First a pageview so the time on page is tracked properly
$this->moveTimeForward($vis, 30); $this->moveTimeForward($vis, 30);
$vis->setUrl('http://example.org/movies'); $vis->setUrl('http://example.org/movies');
$vis->setGenerationTime(666);
self::checkResponse($vis->doTrackPageView('Movie Theater')); self::checkResponse($vis->doTrackPageView('Movie Theater'));
$this->moveTimeForward($vis, 31); $this->moveTimeForward($vis, 31);
......
...@@ -71,13 +71,25 @@ class Test_Piwik_Integration_CustomEvents extends IntegrationTestCase ...@@ -71,13 +71,25 @@ class Test_Piwik_Integration_CustomEvents extends IntegrationTestCase
'setDateLastN' => false, 'setDateLastN' => false,
'testSuffix' => '_eventCategoryOrNameMatch') 'testSuffix' => '_eventCategoryOrNameMatch')
), ),
// eventAction should not match any page view
array('Actions.getPageUrls', array( array('Actions.getPageUrls', array(
'idSite' => $idSite1, 'idSite' => $idSite1,
'date' => $dateTime, 'date' => $dateTime,
'periods' => $dayPeriod, 'periods' => $dayPeriod,
'segment' => "eventAction=@play", 'segment' => "eventAction=@play",
'setDateLastN' => false, 'setDateLastN' => false,
'testSuffix' => '_eventActionContainsPlay') 'testSuffix' => '_eventSegmentMatchNoAction')
),
// eventValue should not match any page view
array('Actions.getPageUrls', array(
'idSite' => $idSite1,
'date' => $dateTime,
'periods' => $dayPeriod,
'segment' => "eventValue>0",
'setDateLastN' => false,
'testSuffix' => '_eventSegmentMatchNoAction')
), ),
); );
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<avg_time_on_page>00:00:00</avg_time_on_page> <avg_time_on_page>00:00:00</avg_time_on_page>
<bounce_rate>0%</bounce_rate> <bounce_rate>0%</bounce_rate>
<exit_rate>100%</exit_rate> <exit_rate>100%</exit_rate>
<avg_time_generation>0s</avg_time_generation> <avg_time_generation>0.67s</avg_time_generation>
</row> </row>
<row> <row>
<label>/webradio</label> <label>/webradio</label>
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<avg_time_on_page>00:24:59</avg_time_on_page> <avg_time_on_page>00:24:59</avg_time_on_page>
<bounce_rate>0%</bounce_rate> <bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate> <exit_rate>0%</exit_rate>
<avg_time_generation>0s</avg_time_generation> <avg_time_generation>0.33s</avg_time_generation>
</row> </row>
</result> </result>
<result prettyDate="Monday 4 January 2010" /> <result prettyDate="Monday 4 January 2010" />
......
...@@ -6,11 +6,15 @@ ...@@ -6,11 +6,15 @@
<nb_uniq_visitors>2</nb_uniq_visitors> <nb_uniq_visitors>2</nb_uniq_visitors>
<nb_hits>2</nb_hits> <nb_hits>2</nb_hits>
<sum_time_spent>0</sum_time_spent> <sum_time_spent>0</sum_time_spent>
<nb_hits_with_time_generation>2</nb_hits_with_time_generation>
<min_time_generation>0.666</min_time_generation>
<max_time_generation>0.666</max_time_generation>
<exit_nb_uniq_visitors>2</exit_nb_uniq_visitors> <exit_nb_uniq_visitors>2</exit_nb_uniq_visitors>
<exit_nb_visits>2</exit_nb_visits> <exit_nb_visits>2</exit_nb_visits>
<avg_time_on_page>0</avg_time_on_page> <avg_time_on_page>0</avg_time_on_page>
<bounce_rate>0%</bounce_rate> <bounce_rate>0%</bounce_rate>
<exit_rate>100%</exit_rate> <exit_rate>100%</exit_rate>
<avg_time_generation>0.666</avg_time_generation>
<url>http://example.org/movies</url> <url>http://example.org/movies</url>
</row> </row>
<row> <row>
...@@ -19,6 +23,9 @@ ...@@ -19,6 +23,9 @@
<nb_uniq_visitors>2</nb_uniq_visitors> <nb_uniq_visitors>2</nb_uniq_visitors>
<nb_hits>2</nb_hits> <nb_hits>2</nb_hits>
<sum_time_spent>2998</sum_time_spent> <sum_time_spent>2998</sum_time_spent>
<nb_hits_with_time_generation>2</nb_hits_with_time_generation>
<min_time_generation>0.333</min_time_generation>
<max_time_generation>0.333</max_time_generation>
<entry_nb_uniq_visitors>2</entry_nb_uniq_visitors> <entry_nb_uniq_visitors>2</entry_nb_uniq_visitors>
<entry_nb_visits>2</entry_nb_visits> <entry_nb_visits>2</entry_nb_visits>
<entry_nb_actions>30</entry_nb_actions> <entry_nb_actions>30</entry_nb_actions>
...@@ -27,6 +34,7 @@ ...@@ -27,6 +34,7 @@
<avg_time_on_page>1499</avg_time_on_page> <avg_time_on_page>1499</avg_time_on_page>
<bounce_rate>0%</bounce_rate> <bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate> <exit_rate>0%</exit_rate>
<avg_time_generation>0.333</avg_time_generation>
<url>http://example.org/webradio</url> <url>http://example.org/webradio</url>
</row> </row>
</result> </result>
\ No newline at end of file
...@@ -5,12 +5,16 @@ ...@@ -5,12 +5,16 @@
<nb_visits>2</nb_visits> <nb_visits>2</nb_visits>
<nb_hits>2</nb_hits> <nb_hits>2</nb_hits>
<sum_time_spent>0</sum_time_spent> <sum_time_spent>0</sum_time_spent>
<nb_hits_with_time_generation>2</nb_hits_with_time_generation>
<min_time_generation>0.666</min_time_generation>
<max_time_generation>0.666</max_time_generation>
<exit_nb_visits>2</exit_nb_visits> <exit_nb_visits>2</exit_nb_visits>
<sum_daily_nb_uniq_visitors>2</sum_daily_nb_uniq_visitors> <sum_daily_nb_uniq_visitors>2</sum_daily_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>2</sum_daily_exit_nb_uniq_visitors> <sum_daily_exit_nb_uniq_visitors>2</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page> <avg_time_on_page>0</avg_time_on_page>
<bounce_rate>0%</bounce_rate> <bounce_rate>0%</bounce_rate>
<exit_rate>100%</exit_rate> <exit_rate>100%</exit_rate>
<avg_time_generation>0.666</avg_time_generation>
<url>http://example.org/movies</url> <url>http://example.org/movies</url>
</row> </row>
<row> <row>
...@@ -18,6 +22,9 @@ ...@@ -18,6 +22,9 @@
<nb_visits>2</nb_visits> <nb_visits>2</nb_visits>
<nb_hits>2</nb_hits> <nb_hits>2</nb_hits>
<sum_time_spent>2998</sum_time_spent> <sum_time_spent>2998</sum_time_spent>
<nb_hits_with_time_generation>2</nb_hits_with_time_generation>
<min_time_generation>0.333</min_time_generation>
<max_time_generation>0.333</max_time_generation>
<entry_nb_visits>2</entry_nb_visits> <entry_nb_visits>2</entry_nb_visits>
<entry_nb_actions>30</entry_nb_actions> <entry_nb_actions>30</entry_nb_actions>
<entry_sum_visit_length>7202</entry_sum_visit_length> <entry_sum_visit_length>7202</entry_sum_visit_length>
...@@ -27,6 +34,7 @@ ...@@ -27,6 +34,7 @@
<avg_time_on_page>1499</avg_time_on_page> <avg_time_on_page>1499</avg_time_on_page>
<bounce_rate>0%</bounce_rate> <bounce_rate>0%</bounce_rate>
<exit_rate>0%</exit_rate> <exit_rate>0%</exit_rate>
<avg_time_generation>0.333</avg_time_generation>
<url>http://example.org/webradio</url> <url>http://example.org/webradio</url>
</row> </row>
</result> </result>
\ No newline at end of file
...@@ -8,5 +8,5 @@ ...@@ -8,5 +8,5 @@
<nb_uniq_outlinks>0</nb_uniq_outlinks> <nb_uniq_outlinks>0</nb_uniq_outlinks>
<nb_searches>0</nb_searches> <nb_searches>0</nb_searches>
<nb_keywords>0</nb_keywords> <nb_keywords>0</nb_keywords>
<avg_time_generation>0</avg_time_generation> <avg_time_generation>0.5</avg_time_generation>
</result> </result>
\ No newline at end of file
...@@ -8,5 +8,5 @@ ...@@ -8,5 +8,5 @@
<nb_uniq_outlinks>0</nb_uniq_outlinks> <nb_uniq_outlinks>0</nb_uniq_outlinks>
<nb_searches>0</nb_searches> <nb_searches>0</nb_searches>
<nb_keywords>0</nb_keywords> <nb_keywords>0</nb_keywords>
<avg_time_generation>0</avg_time_generation> <avg_time_generation>0.5</avg_time_generation>
</result> </result>
\ No newline at end of file
...@@ -178,6 +178,7 @@ ...@@ -178,6 +178,7 @@
<pageIdAction>2</pageIdAction> <pageIdAction>2</pageIdAction>
<pageId>1</pageId> <pageId>1</pageId>
<generationTime>0.33s</generationTime>
<timeSpent>60</timeSpent> <timeSpent>60</timeSpent>
<timeSpentPretty>1 min 0s</timeSpentPretty> <timeSpentPretty>1 min 0s</timeSpentPretty>
<icon /> <icon />
...@@ -324,6 +325,7 @@ ...@@ -324,6 +325,7 @@
<pageIdAction>12</pageIdAction> <pageIdAction>12</pageIdAction>
<pageId>9</pageId> <pageId>9</pageId>
<generationTime>0.67s</generationTime>
<timeSpent>60</timeSpent> <timeSpent>60</timeSpent>
<timeSpentPretty>1 min 0s</timeSpentPretty> <timeSpentPretty>1 min 0s</timeSpentPretty>
<icon /> <icon />
...@@ -654,6 +656,7 @@ ...@@ -654,6 +656,7 @@
<pageIdAction>2</pageIdAction> <pageIdAction>2</pageIdAction>
<pageId>21</pageId> <pageId>21</pageId>
<generationTime>0.33s</generationTime>
<timeSpent>60</timeSpent> <timeSpent>60</timeSpent>
<timeSpentPretty>1 min 0s</timeSpentPretty> <timeSpentPretty>1 min 0s</timeSpentPretty>
<icon /> <icon />
...@@ -800,6 +803,7 @@ ...@@ -800,6 +803,7 @@
<pageIdAction>12</pageIdAction> <pageIdAction>12</pageIdAction>
<pageId>29</pageId> <pageId>29</pageId>
<generationTime>0.67s</generationTime>
<timeSpent>60</timeSpent> <timeSpent>60</timeSpent>
<timeSpentPretty>1 min 0s</timeSpentPretty> <timeSpentPretty>1 min 0s</timeSpentPretty>
<icon /> <icon />
......
...@@ -178,6 +178,7 @@ ...@@ -178,6 +178,7 @@
<pageIdAction>2</pageIdAction> <pageIdAction>2</pageIdAction>
<pageId>1</pageId> <pageId>1</pageId>
<generationTime>0.33s</generationTime>
<timeSpent>60</timeSpent> <timeSpent>60</timeSpent>
<timeSpentPretty>1 min 0s</timeSpentPretty> <timeSpentPretty>1 min 0s</timeSpentPretty>
<icon /> <icon />
...@@ -324,6 +325,7 @@ ...@@ -324,6 +325,7 @@
<pageIdAction>12</pageIdAction> <pageIdAction>12</pageIdAction>
<pageId>9</pageId> <pageId>9</pageId>
<generationTime>0.67s</generationTime>
<timeSpent>60</timeSpent> <timeSpent>60</timeSpent>
<timeSpentPretty>1 min 0s</timeSpentPretty> <timeSpentPretty>1 min 0s</timeSpentPretty>
<icon /> <icon />
...@@ -654,6 +656,7 @@ ...@@ -654,6 +656,7 @@
<pageIdAction>2</pageIdAction> <pageIdAction>2</pageIdAction>
<pageId>21</pageId> <pageId>21</pageId>
<generationTime>0.33s</generationTime>
<timeSpent>60</timeSpent> <timeSpent>60</timeSpent>
<timeSpentPretty>1 min 0s</timeSpentPretty> <timeSpentPretty>1 min 0s</timeSpentPretty>
<icon /> <icon />
...@@ -800,6 +803,7 @@ ...@@ -800,6 +803,7 @@
<pageIdAction>12</pageIdAction> <pageIdAction>12</pageIdAction>
<pageId>29</pageId> <pageId>29</pageId>
<generationTime>0.67s</generationTime>
<timeSpent>60</timeSpent> <timeSpent>60</timeSpent>
<timeSpentPretty>1 min 0s</timeSpentPretty> <timeSpentPretty>1 min 0s</timeSpentPretty>
<icon /> <icon />
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter