public function __construct(ArchiveProcessor\Parameters $params, $isArchiveTemporary)
 {
     $this->idArchive = false;
     $this->idSite = $params->getSite()->getId();
     $this->segment = $params->getSegment();
     $this->period = $params->getPeriod();
     $this->doneFlag = Rules::getDoneStringFlagFor($this->segment, $this->period->getLabel(), $params->getRequestedPlugin());
     $this->isArchiveTemporary = $isArchiveTemporary;
     $this->dateStart = $this->period->getDateStart();
 }
 public static function getArchiveIdAndVisits(ArchiveProcessor\Parameters $params, $minDatetimeArchiveProcessedUTC)
 {
     $dateStart = $params->getPeriod()->getDateStart();
     $bindSQL = array($params->getSite()->getId(), $dateStart->toString('Y-m-d'), $params->getPeriod()->getDateEnd()->toString('Y-m-d'), $params->getPeriod()->getId());
     $timeStampWhere = '';
     if ($minDatetimeArchiveProcessedUTC) {
         $timeStampWhere = " AND ts_archived >= ? ";
         $bindSQL[] = Date::factory($minDatetimeArchiveProcessedUTC)->getDatetime();
     }
     $requestedPlugin = $params->getRequestedPlugin();
     $segment = $params->getSegment();
     $isSkipAggregationOfSubTables = $params->isSkipAggregationOfSubTables();
     $plugins = array("VisitsSummary", $requestedPlugin);
     $sqlWhereArchiveName = self::getNameCondition($plugins, $segment, $isSkipAggregationOfSubTables);
     $sqlQuery = "\tSELECT idarchive, value, name, date1 as startDate\n\t\t\t\t\t\tFROM " . ArchiveTableCreator::getNumericTable($dateStart) . "``\n\t\t\t\t\t\tWHERE idsite = ?\n\t\t\t\t\t\t\tAND date1 = ?\n\t\t\t\t\t\t\tAND date2 = ?\n\t\t\t\t\t\t\tAND period = ?\n\t\t\t\t\t\t\tAND ( ({$sqlWhereArchiveName})\n\t\t\t\t\t\t\t\t  OR name = '" . self::NB_VISITS_RECORD_LOOKED_UP . "'\n\t\t\t\t\t\t\t\t  OR name = '" . self::NB_VISITS_CONVERTED_RECORD_LOOKED_UP . "')\n\t\t\t\t\t\t\t{$timeStampWhere}\n\t\t\t\t\t\tORDER BY idarchive DESC";
     $results = Db::fetchAll($sqlQuery, $bindSQL);
     if (empty($results)) {
         return false;
     }
     $idArchive = self::getMostRecentIdArchiveFromResults($segment, $requestedPlugin, $isSkipAggregationOfSubTables, $results);
     $idArchiveVisitsSummary = self::getMostRecentIdArchiveFromResults($segment, "VisitsSummary", $isSkipAggregationOfSubTables, $results);
     list($visits, $visitsConverted) = self::getVisitsMetricsFromResults($idArchive, $idArchiveVisitsSummary, $results);
     if ($visits === false && $idArchive === false) {
         return false;
     }
     return array($idArchive, $visits, $visitsConverted);
 }
 public static function getArchiveIdAndVisits(ArchiveProcessor\Parameters $params, $minDatetimeArchiveProcessedUTC)
 {
     $idSite = $params->getSite()->getId();
     $period = $params->getPeriod()->getId();
     $dateStart = $params->getPeriod()->getDateStart();
     $dateStartIso = $dateStart->toString('Y-m-d');
     $dateEndIso = $params->getPeriod()->getDateEnd()->toString('Y-m-d');
     $numericTable = ArchiveTableCreator::getNumericTable($dateStart);
     $minDatetimeIsoArchiveProcessedUTC = null;
     if ($minDatetimeArchiveProcessedUTC) {
         $minDatetimeIsoArchiveProcessedUTC = Date::factory($minDatetimeArchiveProcessedUTC)->getDatetime();
     }
     $requestedPlugin = $params->getRequestedPlugin();
     $segment = $params->getSegment();
     $isSkipAggregationOfSubTables = $params->isSkipAggregationOfSubTables();
     $plugins = array("VisitsSummary", $requestedPlugin);
     $doneFlags = self::getDoneFlags($plugins, $segment, $isSkipAggregationOfSubTables);
     $possibleValues = self::getPossibleValues();
     $results = self::getModel()->getArchiveIdAndVisits($numericTable, $idSite, $period, $dateStartIso, $dateEndIso, $minDatetimeIsoArchiveProcessedUTC, $doneFlags, $possibleValues);
     if (empty($results)) {
         return false;
     }
     $idArchive = self::getMostRecentIdArchiveFromResults($segment, $requestedPlugin, $isSkipAggregationOfSubTables, $results);
     $idArchiveVisitsSummary = self::getMostRecentIdArchiveFromResults($segment, "VisitsSummary", $isSkipAggregationOfSubTables, $results);
     list($visits, $visitsConverted) = self::getVisitsMetricsFromResults($idArchive, $idArchiveVisitsSummary, $results);
     if (false === $visits && false === $idArchive) {
         return false;
     }
     return array($idArchive, $visits, $visitsConverted);
 }
Beispiel #4
0
 /**
  * Returns the minimum archive processed datetime to look at. Only public for tests.
  *
  * @return int|bool  Datetime timestamp, or false if must look at any archive available
  */
 protected function getMinTimeArchiveProcessed()
 {
     $endDateTimestamp = self::determineIfArchivePermanent($this->params->getDateEnd());
     $isArchiveTemporary = $endDateTimestamp === false;
     $this->temporaryArchive = $isArchiveTemporary;
     if ($endDateTimestamp) {
         // Permanent archive
         return $endDateTimestamp;
     }
     // Temporary archive
     return Rules::getMinTimeProcessedForTemporaryArchive($this->params->getDateStart(), $this->params->getPeriod(), $this->params->getSegment(), $this->params->getSite());
 }
 /**
  * Whether the specified plugin's reports should be archived
  * @param string $pluginName
  * @return bool
  */
 protected function shouldProcessReportsForPlugin($pluginName)
 {
     if ($this->params->getRequestedPlugin() == $pluginName) {
         return true;
     }
     if (Rules::shouldProcessReportsAllPlugins($this->params->getIdSites(), $this->params->getSegment(), $this->params->getPeriod()->getLabel())) {
         return true;
     }
     if (!\Piwik\Plugin\Manager::getInstance()->isPluginLoaded($this->params->getRequestedPlugin())) {
         return true;
     }
     return false;
 }
 /**
  * Constructor.
  *
  * @param \Piwik\ArchiveProcessor\Parameters $params
  */
 public function __construct(Parameters $params)
 {
     $this->dateStart = $params->getDateStart();
     $this->dateEnd = $params->getDateEnd();
     $this->segment = $params->getSegment();
     $this->sites = $params->getIdSites();
 }
 protected function getArchive()
 {
     if (empty($this->archive)) {
         $subPeriods = $this->params->getSubPeriods();
         $idSites = $this->params->getIdSites();
         $this->archive = Archive::factory($this->params->getSegment(), $subPeriods, $idSites);
     }
     return $this->archive;
 }
Beispiel #8
0
 private function shouldArchiveForSiteEvenWhenNoVisits()
 {
     $idSitesToArchive = $this->getIdSitesToArchiveWhenNoVisits();
     return in_array($this->params->getSite()->getId(), $idSitesToArchive);
 }