Piwik\Plugins\Actions\Reports\Base::addExcludeLowPopDisplayProperties PHP Method

addExcludeLowPopDisplayProperties() protected method

protected addExcludeLowPopDisplayProperties ( ViewDataTable $view )
$view Piwik\Plugin\ViewDataTable
    protected function addExcludeLowPopDisplayProperties(ViewDataTable $view)
    {
        if (Common::getRequestVar('enable_filter_excludelowpop', '0', 'string') != '0') {
            if (Common::getRequestVar('flat', 0, 'int') === 1) {
                $view->requestConfig->filter_excludelowpop = 'nb_hits';
            } else {
                $view->requestConfig->filter_excludelowpop = Metrics::INDEX_PAGE_NB_HITS;
            }
            $view->requestConfig->filter_excludelowpop_value = function () {
                // computing minimum value to exclude (2 percent of the total number of actions)
                $visitsInfo = \Piwik\Plugins\VisitsSummary\Controller::getVisitsSummary()->getFirstRow();
                $nbActions = $visitsInfo->getColumn('nb_actions');
                $nbActionsLowPopulationThreshold = floor(0.02 * $nbActions);
                // we remove 1 to make sure some actions/downloads are displayed in the case we have a very few of them
                // and each of them has 1 or 2 hits...
                return min($visitsInfo->getColumn('max_actions') - 1, $nbActionsLowPopulationThreshold - 1);
            };
        }
    }