private function generateMoverAndShaker($totalValue, $lastTotalValue, $orderBy = null, $limitIncreaser = 99, $limitDecreaser = 99)
 {
     if (is_null($orderBy)) {
         $orderBy = InsightReport::ORDER_BY_ABSOLUTE;
     }
     $reportMetadata = array('name' => 'TestReport', 'metrics' => array('nb_visits' => 'Visits'));
     $report = $this->insightReport->generateMoverAndShaker($reportMetadata, 'day', '2012-12-12', '2012-12-11', 'nb_visits', $this->currentTable, $this->pastTable, $totalValue, $lastTotalValue, $orderBy, $limitIncreaser, $limitDecreaser);
     return $report;
 }
Exemple #2
0
 /**
  * Detects the movers and shakers of a given date / report combination. A mover and shakers has an higher impact
  * than other rows on average. For instance if a sites pageviews increase by 10% a page that increased by 40% at the
  * same time contributed significantly more to the success than the average of 10%.
  *
  * @param int $idSite
  * @param string $period
  * @param string $date
  * @param string $reportUniqueId   eg 'Actions_getPageUrls'. An id like 'Goals_getVisitsUntilConversion_idGoal--4' works as well.
  * @param bool|string $segment
  * @param int $comparedToXPeriods
  * @param int $limitIncreaser      Value '0' ignores all increasers
  * @param int $limitDecreaser      Value '0' ignores all decreasers
  *
  * @return DataTable
  *
  * @throws \Exception In case a report having the given ID does not exist
  * @throws \Exception In case the report exists but does not return a dataTable
  */
 public function getMoversAndShakers($idSite, $period, $date, $reportUniqueId, $segment = false, $comparedToXPeriods = 1, $limitIncreaser = 4, $limitDecreaser = 4)
 {
     Piwik::checkUserHasViewAccess(array($idSite));
     $metric = 'nb_visits';
     $orderBy = InsightReport::ORDER_BY_ABSOLUTE;
     $reportMetadata = $this->model->getReportByUniqueId($idSite, $reportUniqueId);
     if (empty($reportMetadata)) {
         throw new \Exception('A report having the ID ' . $reportUniqueId . ' does not exist');
     }
     $totalValue = $this->model->getTotalValue($idSite, $period, $date, $metric, $segment);
     $currentReport = $this->model->requestReport($idSite, $period, $date, $reportUniqueId, $metric, $segment);
     $this->checkReportIsValid($currentReport);
     $lastDate = $this->model->getLastDate($date, $period, $comparedToXPeriods);
     $lastTotalValue = $this->model->getTotalValue($idSite, $period, $lastDate, $metric, $segment);
     $lastReport = $this->model->requestReport($idSite, $period, $lastDate, $reportUniqueId, $metric, $segment);
     $this->checkReportIsValid($lastReport);
     $insight = new InsightReport();
     return $insight->generateMoverAndShaker($reportMetadata, $period, $date, $lastDate, $metric, $currentReport, $lastReport, $totalValue, $lastTotalValue, $orderBy, $limitIncreaser, $limitDecreaser);
 }