public function callAggregateAllPlugins($visits, $visitsConverted, $forceArchivingWithoutVisits = false)
    {
        Log::debug("PluginsArchiver::%s: Initializing archiving process for all plugins [visits = %s, visits converted = %s]",
            __FUNCTION__, $visits, $visitsConverted);

        /** @var Logger $performanceLogger */
        $performanceLogger = StaticContainer::get(Logger::class);

        $this->archiveProcessor->setNumberOfVisits($visits, $visitsConverted);

        $archivers = static::getPluginArchivers();

        foreach ($archivers as $pluginName => $archiverClass) {
            // We clean up below all tables created during this function call (and recursive calls)
            $latestUsedTableId = Manager::getInstance()->getMostRecentTableId();

            /** @var Archiver $archiver */
            $archiver = $this->makeNewArchiverObject($archiverClass, $pluginName);

            if (!$archiver->isEnabled()) {
                Log::debug("PluginsArchiver::%s: Skipping archiving for plugin '%s' (disabled).", __FUNCTION__, $pluginName);
                continue;
            }

            if (!$forceArchivingWithoutVisits && !$visits && !$archiver->shouldRunEvenWhenNoVisits()) {
                Log::debug("PluginsArchiver::%s: Skipping archiving for plugin '%s' (no visits).", __FUNCTION__, $pluginName);
                continue;
            }

            if ($this->shouldProcessReportsForPlugin($pluginName)) {

                $this->logAggregator->setQueryOriginHint($pluginName);

                try {
                    $timer = new Timer();
                    if ($this->shouldAggregateFromRawData) {
                        Log::debug("PluginsArchiver::%s: Archiving day reports for plugin '%s'.", __FUNCTION__, $pluginName);

                        $archiver->callAggregateDayReport();
                    } else {
                        Log::debug("PluginsArchiver::%s: Archiving period reports for plugin '%s'.", __FUNCTION__, $pluginName);

                        $archiver->callAggregateMultipleReports();
                    }

                    $this->logAggregator->setQueryOriginHint('');

                    $performanceLogger->logMeasurement('plugin', $pluginName, $this->params, $timer);

                    Log::debug("PluginsArchiver::%s: %s while archiving %s reports for plugin '%s' %s.",
                        __FUNCTION__,
                        $timer->getMemoryLeak(),
                        $this->params->getPeriod()->getLabel(),
                        $pluginName,
                        $this->params->getSegment() ? sprintf("(for segment = '%s')", $this->params->getSegment()->getString()) : ''
                    );
                } catch (Exception $e) {
                    throw new PluginsArchiverException($e->getMessage() . " - in plugin $pluginName", $e->getCode(), $e);
                }
            } else {
                Log::debug("PluginsArchiver::%s: Not archiving reports for plugin '%s'.", __FUNCTION__, $pluginName);
            }

            Manager::getInstance()->deleteAll($latestUsedTableId);
            unset($archiver);
        }
    }
public function callAggregateAllPlugins($visits, $visitsConverted, $forceArchivingWithoutVisits = false)
    {
        Log::debug("PluginsArchiver::%s: Initializing archiving process for all plugins [visits = %s, visits converted = %s]",
            __FUNCTION__, $visits, $visitsConverted);

        /** @var Logger $performanceLogger */
        $performanceLogger = StaticContainer::get(Logger::class);

        $this->archiveProcessor->setNumberOfVisits($visits, $visitsConverted);

        $archivers = static::getPluginArchivers();

        foreach ($archivers as $pluginName => $archiverClass) {
            // We clean up below all tables created during this function call (and recursive calls)
            $latestUsedTableId = Manager::getInstance()->getMostRecentTableId();

            /** @var Archiver $archiver */
            $archiver = $this->makeNewArchiverObject($archiverClass, $pluginName);

            if (!$archiver->isEnabled()) {
                Log::debug("PluginsArchiver::%s: Skipping archiving for plugin '%s' (disabled).", __FUNCTION__, $pluginName);
                continue;
            }

            if (!$forceArchivingWithoutVisits && !$visits && !$archiver->shouldRunEvenWhenNoVisits()) {
                Log::debug("PluginsArchiver::%s: Skipping archiving for plugin '%s' (no visits).", __FUNCTION__, $pluginName);
                continue;
            }

            if ($this->shouldProcessReportsForPlugin($pluginName)) {

                $this->logAggregator->setQueryOriginHint($pluginName);

                try {
                    $timer = new Timer();
                    if ($this->shouldAggregateFromRawData) {
                        Log::debug("PluginsArchiver::%s: Archiving day reports for plugin '%s'.", __FUNCTION__, $pluginName);

                        $archiver->callAggregateDayReport();
                    } else {
                        Log::debug("PluginsArchiver::%s: Archiving period reports for plugin '%s'.", __FUNCTION__, $pluginName);

                        $archiver->callAggregateMultipleReports();
                    }

                    $this->logAggregator->setQueryOriginHint('');

                    $performanceLogger->logMeasurement('plugin', $pluginName, $this->params, $timer);

                    Log::debug("PluginsArchiver::%s: %s while archiving %s reports for plugin '%s' %s.",
                        __FUNCTION__,
                        $timer->getMemoryLeak(),
                        $this->params->getPeriod()->getLabel(),
                        $pluginName,
                        $this->params->getSegment() ? sprintf("(for segment = '%s')", $this->params->getSegment()->getString()) : ''
                    );
                } catch (Exception $e) {
                    throw new PluginsArchiverException($e->getMessage() . " - in plugin $pluginName", $e->getCode(), $e);
                }
            } else {
                Log::debug("PluginsArchiver::%s: Not archiving reports for plugin '%s'.", __FUNCTION__, $pluginName);
            }

            Manager::getInstance()->deleteAll($latestUsedTableId);
            unset($archiver);
        }
    }
public function callAggregateAllPlugins ( $ visits , $ visitsConverted , $ forceArchivingWithoutVisits = false ) { Log :: debug ( "PluginsArchiver::%s: Initializing archiving process for all plugins [visits = %s, visits converted = %s]" , __FUNCTION__ , $ visits , $ visitsConverted ) ; /** @var Logger $performanceLogger */ $ performanceLogger = StaticContainer :: get ( Logger :: class ) ; $ this -> archiveProcessor -> setNumberOfVisits ( $ visits , $ visitsConverted ) ; $ archivers = static :: getPluginArchivers ( ) ; foreach ( $ archivers as $ pluginName => $ archiverClass ) { // We clean up below all tables created during this function call (and recursive calls) $ latestUsedTableId = Manager :: getInstance ( ) -> getMostRecentTableId ( ) ; /** @var Archiver $archiver */ $ archiver = $ this -> makeNewArchiverObject ( $ archiverClass , $ pluginName ) ; if ( ! $ archiver -> isEnabled ( ) ) { Log :: debug ( "PluginsArchiver::%s: Skipping archiving for plugin '%s' (disabled)." , __FUNCTION__ , $ pluginName ) ; continue ; } if ( ! $ forceArchivingWithoutVisits && ! $ visits && ! $ archiver -> shouldRunEvenWhenNoVisits ( ) ) { Log :: debug ( "PluginsArchiver::%s: Skipping archiving for plugin '%s' (no visits)." , __FUNCTION__ , $ pluginName ) ; continue ; } if ( $ this -> shouldProcessReportsForPlugin ( $ pluginName ) ) { $ this -> logAggregator -> setQueryOriginHint ( $ pluginName ) ; try { $ timer = new Timer ( ) ; if ( $ this -> shouldAggregateFromRawData ) { Log :: debug ( "PluginsArchiver::%s: Archiving day reports for plugin '%s'." , __FUNCTION__ , $ pluginName ) ; $ archiver -> callAggregateDayReport ( ) ; } else { Log :: debug ( "PluginsArchiver::%s: Archiving period reports for plugin '%s'." , __FUNCTION__ , $ pluginName ) ; $ archiver -> callAggregateMultipleReports ( ) ; } $ this -> logAggregator -> setQueryOriginHint ( '' ) ; $ performanceLogger -> logMeasurement ( 'plugin' , $ pluginName , $ this -> params , $ timer ) ; Log :: debug ( "PluginsArchiver::%s: %s while archiving %s reports for plugin '%s' %s." , __FUNCTION__ , $ timer -> getMemoryLeak ( ) , $ this -> params -> getPeriod ( ) -> getLabel ( ) , $ pluginName , $ this -> params -> getSegment ( ) ? sprintf ( "(for segment = '%s')" , $ this -> params -> getSegment ( ) -> getString ( ) ) : '' ) ; } catch ( Exception $ e ) { throw new PluginsArchiverException ( $ e -> getMessage ( ) . " - in plugin $pluginName" , $ e -> getCode ( ) , $ e ) ; } } else { Log :: debug ( "PluginsArchiver::%s: Not archiving reports for plugin '%s'." , __FUNCTION__ , $ pluginName ) ; } Manager :: getInstance ( ) -> deleteAll ( $ latestUsedTableId ) ; unset ( $ archiver ) ; } }
Instantiates the Archiver class in each plugin that defines it,
and triggers Aggregation processing on these plugins.
Instantiates the Archiver class in each plugin that defines it and triggers Aggregation processing on these plugins .