/** * Builds an array of Piwik_Archive of a given date range * * @param Piwik_Site $oSite * @param string $strPeriod eg. 'day' 'week' etc. * @param string $strDate A date range, eg. 'last10', 'previous5' or 'YYYY-MM-DD,YYYY-MM-DD' */ function __construct(Piwik_Site $oSite, $strPeriod, $strDate, Piwik_Segment $segment) { $rangePeriod = new Piwik_Period_Range($strPeriod, $strDate, $oSite->getTimezone()); foreach ($rangePeriod->getSubperiods() as $subPeriod) { $startDate = $subPeriod->getDateStart(); $archive = Piwik_Archive::build($oSite->getId(), $strPeriod, $startDate, $segment->getString()); $archive->setSegment($segment); $this->archives[] = $archive; } }
/** * Builds an array of Piwik_Archive of a given date range * * @param Piwik_Site $oSite * @param string $strPeriod eg. 'day' 'week' etc. * @param string $strDate A date range, eg. 'last10', 'previous5' or 'YYYY-MM-DD,YYYY-MM-DD' */ function __construct(Piwik_Site $oSite, $strPeriod, $strDate) { $rangePeriod = new Piwik_Period_Range($strPeriod, $strDate); foreach ($rangePeriod->getSubperiods() as $subPeriod) { $startDate = $subPeriod->getDateStart(); $archive = Piwik_Archive::build($oSite->getId(), $strPeriod, $startDate); $archive->prepareArchive(); $timestamp = $archive->getTimestampStartDate(); $this->archives[$timestamp] = $archive; } ksort($this->archives); }
/** * Builds an array of Piwik_Archive of a given date range * * @param Piwik_Site $oSite * @param string $strPeriod eg. 'day' 'week' etc. * @param string $strDate A date range, eg. 'last10', 'previous5' or 'YYYY-MM-DD,YYYY-MM-DD' */ function __construct(Piwik_Site $oSite, $strPeriod, $strDate) { $rangePeriod = new Piwik_Period_Range($strPeriod, $strDate); // TODO fix this when aggregating data from multiple websites // CAREFUL this class wouldnt work as is if handling archives from multiple websites // works only when managing archives from multiples dates/periods foreach ($rangePeriod->getSubperiods() as $subPeriod) { $startDate = $subPeriod->getDateStart(); $archive = Piwik_Archive::build($oSite->getId(), $strPeriod, $startDate); $archive->prepareArchive(); $timestamp = $archive->getTimestampStartDate(); $this->archives[$timestamp] = $archive; } ksort($this->archives); }
/** * Inits the object */ protected function loadArchiveProperties() { $this->idsite = $this->site->getId(); $this->periodId = $this->period->getId(); $this->dateStart = $this->period->getDateStart(); $this->dateEnd = $this->period->getDateEnd(); $this->tableArchiveNumeric = new Piwik_TablePartitioning_Monthly('archive_numeric'); $this->tableArchiveNumeric->setIdSite($this->idsite); $this->tableArchiveNumeric->setTimestamp($this->dateStart->get()); $this->tableArchiveBlob = new Piwik_TablePartitioning_Monthly('archive_blob'); $this->tableArchiveBlob->setIdSite($this->idsite); $this->tableArchiveBlob->setTimestamp($this->dateStart->get()); $this->strDateStart = $this->dateStart->toString(); $this->strDateEnd = $this->dateEnd->toString(); // if the current archive is a DAY and if it's today, // we set this maxTimestampArchive that defines the lifetime value of today's archive $this->maxTimestampArchive = 0; if ($this->period->getNumberOfSubperiods() == 0 && $this->period->toString() == date("Y-m-d")) { $this->maxTimestampArchive = time() - Zend_Registry::get('config')->General->time_before_today_archive_considered_outdated; $browserArchivingEnabled = Zend_Registry::get('config')->General->enable_browser_archiving_triggering; // see #1150; if new archives are not triggered from the browser, // we still want to try and return the latest archive available for today (rather than return nothing) if (!$browserArchivingEnabled) { $this->maxTimestampArchive = 0; } } else { if ($this->period->isFinished()) { $this->maxTimestampArchive = $this->period->getDateEnd()->setTime('00:00:00')->addDay(1)->getTimestamp(); } else { $this->maxTimestampArchive = Piwik_Date::today()->getTimestamp(); } } $db = Zend_Registry::get('db'); $this->compressBlob = $db->hasBlobDataType(); }
/** * Returns the Id site associated with this archive * * @return int */ public function getIdSite() { return $this->site->getId(); }
/** * Inits the object * * @return void */ protected function loadArchiveProperties() { $this->idsite = $this->site->getId(); $this->periodId = $this->period->getId(); $this->dateStart = $this->period->getDateStart(); $this->dateEnd = $this->period->getDateEnd(); $this->tableArchiveNumeric = new Piwik_TablePartitioning_Monthly('archive_numeric'); $this->tableArchiveNumeric->setIdSite($this->idsite); $this->tableArchiveNumeric->setTimestamp($this->dateStart->get()); $this->tableArchiveBlob = new Piwik_TablePartitioning_Monthly('archive_blob'); $this->tableArchiveBlob->setIdSite($this->idsite); $this->tableArchiveBlob->setTimestamp($this->dateStart->get()); $this->strDateStart = $this->dateStart->toString(); $this->strDateEnd = $this->dateEnd->toString(); // if the current archive is a DAY and if it's today, // we set this maxTimestampArchive that defines the lifetime value of today's archive $this->maxTimestampArchive = 0; if ($this->period->getNumberOfSubperiods() == 0 && $this->period->toString() == date("Y-m-d")) { $this->maxTimestampArchive = time() - Zend_Registry::get('config')->General->time_before_today_archive_considered_outdated; } else { if ($this->period->isFinished()) { $this->maxTimestampArchive = $this->period->getDateEnd()->setTime('00:00:00')->addDay(1)->getTimestamp(); } else { $this->maxTimestampArchive = Piwik_Date::today()->getTimestamp(); } } }
/** * Sets object attributes that will be used throughout the process */ public function init() { $this->idsite = $this->site->getId(); $this->periodId = $this->period->getId(); $dateStartLocalTimezone = $this->period->getDateStart(); $dateEndLocalTimezone = $this->period->getDateEnd(); $this->tableArchiveNumeric = self::makeNumericArchiveTable($this->period); $this->tableArchiveBlob = self::makeBlobArchiveTable($this->period); $dateStartUTC = $dateStartLocalTimezone->setTimezone($this->site->getTimezone()); $dateEndUTC = $dateEndLocalTimezone->setTimezone($this->site->getTimezone()); $this->startDatetimeUTC = $dateStartUTC->getDateStartUTC(); $this->endDatetimeUTC = $dateEndUTC->getDateEndUTC(); $this->startTimestampUTC = $dateStartUTC->getTimestamp(); $this->endTimestampUTC = strtotime($this->endDatetimeUTC); $this->minDatetimeArchiveProcessedUTC = $this->getMinTimeArchivedProcessed(); $db = Zend_Registry::get('db'); $this->compressBlob = $db->hasBlobDataType(); }
/** * Inits the object */ protected function loadArchiveProperties() { $this->idsite = $this->site->getId(); $this->periodId = $this->period->getId(); $this->dateStart = $this->period->getDateStart(); $this->dateEnd = $this->period->getDateEnd(); $this->tableArchiveNumeric = new Piwik_TablePartitioning_Monthly('archive_numeric'); $this->tableArchiveNumeric->setIdSite($this->idsite); $this->tableArchiveNumeric->setTimestamp($this->dateStart->get()); $this->tableArchiveBlob = new Piwik_TablePartitioning_Monthly('archive_blob'); $this->tableArchiveBlob->setIdSite($this->idsite); $this->tableArchiveBlob->setTimestamp($this->dateStart->get()); $this->strDateStart = $this->dateStart->toString(); $this->strDateEnd = $this->dateEnd->toString(); // if the current archive is a DAY and if it's today, // we set this maxTimestampArchive that defines the lifetime value of today's archive $this->maxTimestampArchive = 0; if( $this->period->getNumberOfSubperiods() == 0 && $this->period->toString() == date("Y-m-d") ) { $this->maxTimestampArchive = time() - Zend_Registry::get('config')->General->time_before_today_archive_considered_outdated; } // either // - if the period we're looking for is finished, we look for a ts_archived that // is greater than the last day of the archive // - if the period we're looking for is not finished, we look for a recent enough archive // recent enough means maxTimestampArchive = 00:00:01 this morning else { if($this->period->isFinished()) { $this->maxTimestampArchive = $this->period->getDateEnd()->setTime('00:00:00')->addDay(1)->getTimestamp(); } else { $this->maxTimestampArchive = Piwik_Date::today()->getTimestamp(); } } $db = Zend_Registry::get('db'); $this->compressBlob = $db->hasBlobDataType(); }
/** * Sets object attributes that will be used throughout the process */ public function init() { $this->idsite = $this->site->getId(); $this->periodId = $this->period->getId(); $dateStartLocalTimezone = $this->period->getDateStart(); $dateEndLocalTimezone = $this->period->getDateEnd(); $this->tableArchiveNumeric = new Piwik_TablePartitioning_Monthly('archive_numeric'); $this->tableArchiveNumeric->setIdSite($this->idsite); $this->tableArchiveNumeric->setTimestamp($dateStartLocalTimezone->getTimestamp()); $this->tableArchiveBlob = new Piwik_TablePartitioning_Monthly('archive_blob'); $this->tableArchiveBlob->setIdSite($this->idsite); $this->tableArchiveBlob->setTimestamp($dateStartLocalTimezone->getTimestamp()); $dateStartUTC = $dateStartLocalTimezone->setTimezone($this->site->getTimezone()); $dateEndUTC = $dateEndLocalTimezone->setTimezone($this->site->getTimezone()); $this->startDatetimeUTC = $dateStartUTC->getDateStartUTC(); $this->endDatetimeUTC = $dateEndUTC->getDateEndUTC(); $this->startTimestampUTC = $dateStartUTC->getTimestamp(); $this->endTimestampUTC = strtotime($this->endDatetimeUTC); $this->minDatetimeArchiveProcessedUTC = $this->getMinTimeArchivedProcessed(); $db = Zend_Registry::get('db'); $this->compressBlob = $db->hasBlobDataType(); }
/** * The archive processing classes have features that might be useful for live querying; * In particular, Piwik_ArchiveProcessing_Day::query*. In order to reuse those methods * outside the actual archiving or to reuse archiving code for live querying, an instance * of archive processing has to be faked. * * For example, this code can be used in an API method: * $archiveProcessing = new Piwik_ArchiveProcessing_Day(); * $archiveProcessing->setSite(new Piwik_Site($idSite)); * $archiveProcessing->setPeriod(Piwik_Period::advancedFactory($period, $date)); * $archiveProcessing->setSegment(new Piwik_Segment($segment, $idSite)); * $archiveProcessing->initForLiveUsage(); * Then, either use $archiveProcessing->query* or pass the instance to the archiving * code of the plugin. Note that even though we use Piwik_ArchiveProcessing_Day, this * works for any $period and $date that has been passed to the API. */ public function initForLiveUsage() { $this->idsite = $this->site->getId(); $this->initDates(); }