diff --git a/plugins/VisitTime/API.php b/plugins/VisitTime/API.php index 2075f18872dfb857dd06dc1fef02862c715bd1b9..add726a9cc63b61f90826ee2e17a47cff0d448c4 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 55be4be8c420788c01ccea1bc954751e0356b86a..7052ae2d51c987c541eeee1d36ab7502691284bd 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 55be4be8c420788c01ccea1bc954751e0356b86a..7052ae2d51c987c541eeee1d36ab7502691284bd 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 1f2fd8f84a3bff371335dd0887af195ace8ff2b2..06100d0440340bfdc992ee9f4fefda94bfcdcf01 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>