From ce0c3dfbb0da6d4ca7edf2b1192d0838f72af42b Mon Sep 17 00:00:00 2001 From: benakamoorthi <benaka.moorthi@gmail.com> Date: Thu, 2 Aug 2012 22:43:03 +0000 Subject: [PATCH] Fixes #3275, fix issue w/ VisitTime.getByDayOfWeek report where sumRow complained of strings being added. git-svn-id: http://dev.piwik.org/svn/trunk@6658 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- plugins/VisitTime/API.php | 15 +++++++++------ ...torTwoVisits__VisitTime.getByDayOfWeek_day.xml | 4 ---- ...ookieSupport__VisitTime.getByDayOfWeek_day.xml | 4 ---- ...derWithItems__VisitTime.getByDayOfWeek_day.xml | 4 ---- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/plugins/VisitTime/API.php b/plugins/VisitTime/API.php index 2075f18872..add726a9cc 100644 --- a/plugins/VisitTime/API.php +++ b/plugins/VisitTime/API.php @@ -77,16 +77,16 @@ class Piwik_VisitTime_API throw new Exception("VisitTime.getByDayOfWeek does not support multiple dates."); } - // get visit data for every day within the supplied period, then... + // metrics to query + $metrics = Piwik_ArchiveProcessing::getCoreMetrics(); + + // get metric data for every day within the supplied period $oSite = new Piwik_Site($idSite); $oPeriod = Piwik_Archive::makePeriodFromQueryParams($oSite, $period, $date); $dateRange = $oPeriod->getDateStart()->toString().','.$oPeriod->getDateEnd()->toString(); - $api = Piwik_VisitsSummary_API::getInstance(); - $dataTable = $api->get($idSite, 'day', $dateRange, $segment)->mergeChildren(); - - // ...group by the day of the week (see below for dayOfWeekFromDate function) - $dataTable->filter('GroupBy', array('label', 'Piwik_VisitTime_dayOfWeekFromDate')); + $archive = Piwik_Archive::build($idSite, 'day', $dateRange, $segment); + $dataTable = $archive->getDataTableFromNumeric($metrics)->mergeChildren(); // if there's no data for this report, don't bother w/ anything else if ($dataTable->getRowsCount() == 0) @@ -94,6 +94,9 @@ class Piwik_VisitTime_API return $dataTable; } + // group by the day of the week (see below for dayOfWeekFromDate function) + $dataTable->filter('GroupBy', array('label', 'Piwik_VisitTime_dayOfWeekFromDate')); + // create new datatable w/ empty rows, then add calculated datatable $rows = array(); foreach (array(1,2,3,4,5,6,7) as $day) diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__VisitTime.getByDayOfWeek_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__VisitTime.getByDayOfWeek_day.xml index 55be4be8c4..7052ae2d51 100755 --- a/tests/integration/expected/test_OneVisitorTwoVisits__VisitTime.getByDayOfWeek_day.xml +++ b/tests/integration/expected/test_OneVisitorTwoVisits__VisitTime.getByDayOfWeek_day.xml @@ -29,14 +29,10 @@ <label>Saturday</label> <nb_visits>2</nb_visits> <bounce_count>1</bounce_count> - <max_actions>7</max_actions> <nb_actions>8</nb_actions> <nb_uniq_visitors>1</nb_uniq_visitors> <nb_visits_converted>2</nb_visits_converted> <sum_visit_length>1621</sum_visit_length> - <bounce_rate>50%</bounce_rate> - <nb_actions_per_visit>4</nb_actions_per_visit> - <avg_time_on_site>811</avg_time_on_site> <day_of_week>6</day_of_week> </row> <row> diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getByDayOfWeek_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getByDayOfWeek_day.xml index 55be4be8c4..7052ae2d51 100755 --- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getByDayOfWeek_day.xml +++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getByDayOfWeek_day.xml @@ -29,14 +29,10 @@ <label>Saturday</label> <nb_visits>2</nb_visits> <bounce_count>1</bounce_count> - <max_actions>7</max_actions> <nb_actions>8</nb_actions> <nb_uniq_visitors>1</nb_uniq_visitors> <nb_visits_converted>2</nb_visits_converted> <sum_visit_length>1621</sum_visit_length> - <bounce_rate>50%</bounce_rate> - <nb_actions_per_visit>4</nb_actions_per_visit> - <avg_time_on_site>811</avg_time_on_site> <day_of_week>6</day_of_week> </row> <row> diff --git a/tests/integration/expected/test_ecommerceOrderWithItems__VisitTime.getByDayOfWeek_day.xml b/tests/integration/expected/test_ecommerceOrderWithItems__VisitTime.getByDayOfWeek_day.xml index 1f2fd8f84a..06100d0440 100755 --- a/tests/integration/expected/test_ecommerceOrderWithItems__VisitTime.getByDayOfWeek_day.xml +++ b/tests/integration/expected/test_ecommerceOrderWithItems__VisitTime.getByDayOfWeek_day.xml @@ -8,14 +8,10 @@ <row> <label>Tuesday</label> <nb_visits>3</nb_visits> - <max_actions>6</max_actions> <nb_actions>13</nb_actions> <nb_uniq_visitors>1</nb_uniq_visitors> <nb_visits_converted>2</nb_visits_converted> <sum_visit_length>5403</sum_visit_length> - <bounce_rate>0%</bounce_rate> - <nb_actions_per_visit>4.3</nb_actions_per_visit> - <avg_time_on_site>1801</avg_time_on_site> <day_of_week>2</day_of_week> </row> <row> -- GitLab