diff --git a/plugins/UserSettings/UserSettings.php b/plugins/UserSettings/UserSettings.php index b246a84f18624d8f135400bb81d4d9f406709425..a1a44401e0b615d7c0a6f859ca3635ee1b54369e 100644 --- a/plugins/UserSettings/UserSettings.php +++ b/plugins/UserSettings/UserSettings.php @@ -407,6 +407,10 @@ class UserSettings extends \Piwik\Plugin $report['documentation'] = $translated; } + if ($apiAction == 'getMobileVsDesktop') { + $report['constantRowsCount'] = true; + } + // getPlugin returns only a subset of metrics if ($apiAction == 'getPlugin') { $report['metrics'] = array( diff --git a/tests/PHPUnit/Integration/ManyVisitorsOneWebsiteTest.php b/tests/PHPUnit/Integration/ManyVisitorsOneWebsiteTest.php index 6aaf58400efc8a6c4e23c9e043ebcb53a6b4aaf6..2acb58a7767d60869faca24a992bf0d63e024db4 100755 --- a/tests/PHPUnit/Integration/ManyVisitorsOneWebsiteTest.php +++ b/tests/PHPUnit/Integration/ManyVisitorsOneWebsiteTest.php @@ -66,6 +66,29 @@ class Test_Piwik_Integration_ManyVisitorsOneWebsiteTest extends IntegrationTestC 'testSuffix' => '_segment_continent', 'segment' => 'continentCode==eur')), + // make sure it is possible to sort getProcessedReport by a processed metric + array('API.getProcessedReport', array('idSite' => $idSite, + 'date' => $dateTime, + 'periods' => 'day', + 'apiModule' => 'Actions', + 'apiAction' => 'getPageUrls', + 'testSuffix' => '_sortByProcessedMetric', + 'otherRequestParameters' => array( + 'filter_sort_column' => 'nb_actions_per_visit' + ))), + + // make sure it is possible to sort getProcessedReport by a processed metric + // it should not remove empty rows if report has constant rows count + array('API.getProcessedReport', array('idSite' => $idSite, + 'date' => $dateTime, + 'periods' => 'day', + 'apiModule' => 'VisitTime', + 'apiAction' => 'getVisitInformationPerServerTime', + 'testSuffix' => '_sortByProcessedMetric_constantRowsCountShouldKeepEmptyRows', + 'otherRequestParameters' => array( + 'filter_sort_column' => 'nb_actions_per_visit' + ))), + array(array('UserCountry.getLocationFromIP', 'Live.getLastVisitsDetails'), array( 'idSite' => $idSite, 'date' => $dateTime, diff --git a/tests/PHPUnit/Integration/expected/test_ManyVisitorsOneWebsiteTest_sortByProcessedMetric__API.getProcessedReport_day.xml b/tests/PHPUnit/Integration/expected/test_ManyVisitorsOneWebsiteTest_sortByProcessedMetric__API.getProcessedReport_day.xml new file mode 100644 index 0000000000000000000000000000000000000000..ad4b1d21f359d0d8e2aab9fdc71a942d96909692 --- /dev/null +++ b/tests/PHPUnit/Integration/expected/test_ManyVisitorsOneWebsiteTest_sortByProcessedMetric__API.getProcessedReport_day.xml @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <website>Site 1</website> + <prettyDate>Sunday 3 January 2010</prettyDate> + <metadata> + <category>Actions</category> + <name>Page URLs</name> + <module>Actions</module> + <action>getPageUrls</action> + <dimension>Page URL</dimension> + <metrics> + <nb_hits>Pageviews</nb_hits> + <nb_visits>Unique Pageviews</nb_visits> + <bounce_rate>Bounce Rate</bounce_rate> + <avg_time_on_page>Avg. time on page</avg_time_on_page> + <exit_rate>Exit rate</exit_rate> + </metrics> + <metricsDocumentation> + <nb_hits>The number of times this page was visited.</nb_hits> + <nb_visits>The number of visits that included this page. If a page was viewed multiple times during one visit, it is only counted once.</nb_visits> + <bounce_rate>The percentage of visits that started on this page and left the website straight away.</bounce_rate> + <avg_time_on_page>The average amount of time visitors spent on this page (only the page, not the entire website).</avg_time_on_page> + <exit_rate>The percentage of visits that left the website after viewing this page.</exit_rate> + </metricsDocumentation> + <documentation>This report contains information about the page URLs that have been visited. <br /> The table is organized hierarchically, the URLs are displayed as a folder structure.<br />Use the plus and minus icons on the left to navigate.</documentation> + <actionToLoadSubTables>getPageUrls</actionToLoadSubTables> + <imageGraphUrl>index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=Actions&apiAction=getPageUrls&period=day&date=2010-01-03</imageGraphUrl> + <imageGraphEvolutionUrl>index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=Actions&apiAction=getPageUrls&period=day&date=2009-12-05,2010-01-03</imageGraphEvolutionUrl> + <uniqueId>Actions_getPageUrls</uniqueId> + </metadata> + <columns> + <label>Page URL</label> + <nb_hits>Pageviews</nb_hits> + <nb_visits>Unique Pageviews</nb_visits> + <bounce_rate>Bounce Rate</bounce_rate> + <avg_time_on_page>Avg. time on page</avg_time_on_page> + <exit_rate>Exit rate</exit_rate> + </columns> + <reportData> + <row> + <label>space</label> + <nb_visits>4</nb_visits> + <nb_hits>4</nb_hits> + <avg_time_on_page>00:06:00</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + </row> + <row> + <label>grue</label> + <nb_visits>4</nb_visits> + <nb_hits>4</nb_hits> + <avg_time_on_page>00:00:00</avg_time_on_page> + <bounce_rate>100%</bounce_rate> + <exit_rate>100%</exit_rate> + </row> + </reportData> + <reportMetadata> + <row> + + </row> + <row> + + </row> + </reportMetadata> + <reportTotal> + <nb_visits>8</nb_visits> + <nb_hits>8</nb_hits> + <entry_bounce_count>4</entry_bounce_count> + <entry_nb_visits>8</entry_nb_visits> + <entry_nb_actions>16</entry_nb_actions> + <exit_nb_visits>4</exit_nb_visits> + </reportTotal> +</result> \ No newline at end of file diff --git a/tests/PHPUnit/Integration/expected/test_ManyVisitorsOneWebsiteTest_sortByProcessedMetric_constantRowsCountShouldKeepEmptyRows__API.getProcessedReport_day.xml b/tests/PHPUnit/Integration/expected/test_ManyVisitorsOneWebsiteTest_sortByProcessedMetric_constantRowsCountShouldKeepEmptyRows__API.getProcessedReport_day.xml new file mode 100644 index 0000000000000000000000000000000000000000..f226c09945df2f615adc767d40328ac3dfcb685e --- /dev/null +++ b/tests/PHPUnit/Integration/expected/test_ManyVisitorsOneWebsiteTest_sortByProcessedMetric_constantRowsCountShouldKeepEmptyRows__API.getProcessedReport_day.xml @@ -0,0 +1,305 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <website>Site 1</website> + <prettyDate>Sunday 3 January 2010</prettyDate> + <metadata> + <category>Visits Summary</category> + <name>Visits by Server Time</name> + <module>VisitTime</module> + <action>getVisitInformationPerServerTime</action> + <dimension>Server time</dimension> + <documentation>This graph shows what time it was in the <strong> server's time zone </strong> during the visits.</documentation> + <constantRowsCount>1</constantRowsCount> + <metrics> + <nb_visits>Visits</nb_visits> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_actions>Actions</nb_actions> + </metrics> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + </processedMetrics> + <metricsDocumentation> + <nb_visits>If a visitor comes to your website for the first time or if he visits a page more than 30 minutes after his last page view, this will be recorded as a new visit.</nb_visits> + <nb_uniq_visitors>The number of unduplicated visitors coming to your website. Every user is only counted once, even if he visits the website multiple times a day.</nb_uniq_visitors> + <nb_actions>The number of actions performed by your visitors. Actions can be page views, internal site searches, downloads or outlinks.</nb_actions> + <nb_actions_per_visit>The average number of actions (page views, site searches, downloads or outlinks) that were performed during the visits.</nb_actions_per_visit> + <avg_time_on_site>The average duration of a visit.</avg_time_on_site> + <bounce_rate>The percentage of visits that only had a single pageview. This means, that the visitor left the website directly from the entrance page.</bounce_rate> + <conversion_rate>The percentage of visits that triggered a goal conversion.</conversion_rate> + <avg_time_on_page>The average amount of time visitors spent on this page (only the page, not the entire website).</avg_time_on_page> + <nb_hits>The number of times this page was visited.</nb_hits> + <exit_rate>The percentage of visits that left the website after viewing this page.</exit_rate> + </metricsDocumentation> + <metricsGoal> + <nb_conversions>Conversions</nb_conversions> + <revenue>Revenue</revenue> + </metricsGoal> + <processedMetricsGoal> + <revenue_per_visit>Revenue per Visit</revenue_per_visit> + </processedMetricsGoal> + <imageGraphUrl>index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=VisitTime&apiAction=getVisitInformationPerServerTime&period=day&date=2010-01-03</imageGraphUrl> + <uniqueId>VisitTime_getVisitInformationPerServerTime</uniqueId> + </metadata> + <columns> + <label>Server time</label> + <nb_visits>Visits</nb_visits> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_actions>Actions</nb_actions> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + <revenue>Revenue</revenue> + </columns> + <reportData> + <row> + <label>12h</label> + <nb_uniq_visitors>4</nb_uniq_visitors> + <nb_visits>4</nb_visits> + <nb_actions>12</nb_actions> + <revenue>$ 40</revenue> + <nb_actions_per_visit>3</nb_actions_per_visit> + <avg_time_on_site>00:21:01</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + </row> + <row> + <label>11h</label> + <nb_uniq_visitors>4</nb_uniq_visitors> + <nb_visits>4</nb_visits> + <nb_actions>4</nb_actions> + <revenue>$ 20</revenue> + <nb_actions_per_visit>1</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>100%</bounce_rate> + </row> + <row> + <label>0h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>1h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>2h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>3h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>4h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>5h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>6h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>7h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>8h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>9h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>10h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>13h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>14h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>15h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>16h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>17h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>18h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>19h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>20h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>21h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>22h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + <row> + <label>23h</label> + <nb_uniq_visitors>0</nb_uniq_visitors> + <nb_visits>0</nb_visits> + <nb_actions>0</nb_actions> + <nb_actions_per_visit>0</nb_actions_per_visit> + <avg_time_on_site>00:00:00</avg_time_on_site> + <bounce_rate>0%</bounce_rate> + <revenue>$ 0</revenue> + </row> + </reportData> + <reportMetadata /> + <reportTotal> + <nb_visits>8</nb_visits> + <nb_uniq_visitors>8</nb_uniq_visitors> + <nb_actions>16</nb_actions> + <nb_visits_converted>0</nb_visits_converted> + <bounce_count>4</bounce_count> + </reportTotal> +</result> \ No newline at end of file