Piwik\Plugins\Insights\API::getMoversAndShakers PHP Method

getMoversAndShakers() public method

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%.
public getMoversAndShakers ( integer $idSite, string $period, string $date, string $reportUniqueId, boolean | string $segment = false, integer $comparedToXPeriods = 1, integer $limitIncreaser = 4, integer $limitDecreaser = 4 ) : DataTable
$idSite integer
$period string
$date string
$reportUniqueId string eg 'Actions_getPageUrls'. An id like 'Goals_getVisitsUntilConversion_idGoal--4' works as well.
$segment boolean | string
$comparedToXPeriods integer
$limitIncreaser integer Value '0' ignores all increasers
$limitDecreaser integer Value '0' ignores all decreasers
return Piwik\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);
    }