| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| namespace Piwik\ArchiveProcessor; |
|
|
| use Piwik\Date; |
| use Piwik\Log; |
| use Piwik\Period; |
| use Piwik\Piwik; |
| use Piwik\Segment; |
| use Piwik\Site; |
|
|
| |
| |
| |
| |
| |
| class Parameters |
| { |
| |
| |
| |
| private $site = null; |
|
|
| |
| |
| |
| private $period = null; |
|
|
| |
| |
| |
| private $segment = null; |
|
|
| |
| |
| |
| private $requestedPlugin = false; |
|
|
| private $onlyArchiveRequestedPlugin = false; |
|
|
| |
| |
| |
| private $archiveOnlyReport = null; |
|
|
| |
| |
| |
| private $isArchiveOnlyReportHandled = false; |
|
|
| |
| |
| |
| private $foundRequestedReports; |
|
|
| |
| |
| |
| public function __construct(Site $site, Period $period, Segment $segment) |
| { |
| $this->site = $site; |
| $this->period = $period; |
| $this->segment = $segment; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| public function setArchiveOnlyReport($archiveOnlyReport) |
| { |
| $this->archiveOnlyReport = $archiveOnlyReport; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getArchiveOnlyReport() |
| { |
| return $this->archiveOnlyReport; |
| } |
|
|
| |
| |
| |
| public function setRequestedPlugin($plugin) |
| { |
| $this->requestedPlugin = $plugin; |
| } |
|
|
| |
| |
| |
| public function onlyArchiveRequestedPlugin() |
| { |
| $this->onlyArchiveRequestedPlugin = true; |
| } |
|
|
| |
| |
| |
| public function shouldOnlyArchiveRequestedPlugin() |
| { |
| return $this->onlyArchiveRequestedPlugin; |
| } |
|
|
| |
| |
| |
| public function getRequestedPlugin() |
| { |
| return $this->requestedPlugin; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getPeriod() |
| { |
| return $this->period; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getSubPeriods() |
| { |
| if ($this->getPeriod()->getLabel() == 'day') { |
| return array( $this->getPeriod() ); |
| } |
| return $this->getPeriod()->getSubperiods(); |
| } |
|
|
| |
| |
| |
| |
| public function getIdSites() |
| { |
| $idSite = $this->getSite()->getId(); |
|
|
| $idSites = array($idSite); |
|
|
| Piwik::postEvent('ArchiveProcessor.Parameters.getIdSites', array(&$idSites, $this->getPeriod())); |
|
|
| return $idSites; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getSite() |
| { |
| return $this->site; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| public function getSegment() |
| { |
| return $this->segment; |
| } |
|
|
| |
| |
| |
| |
| |
| public function getDateEnd() |
| { |
| return $this->getPeriod()->getDateEnd()->setTimezone($this->getSite()->getTimezone()); |
| } |
|
|
| |
| |
| |
| |
| |
| public function getDateStart() |
| { |
| return $this->getPeriod()->getDateStart()->setTimezone($this->getSite()->getTimezone()); |
| } |
|
|
| |
| |
| |
| |
| |
| public function getDateTimeStart() |
| { |
| return $this->getPeriod()->getDateTimeStart()->setTimezone($this->getSite()->getTimezone()); |
| } |
|
|
| |
| |
| |
| |
| |
| public function getDateTimeEnd() |
| { |
| return $this->getPeriod()->getDateTimeEnd()->setTimezone($this->getSite()->getTimezone()); |
| } |
|
|
| |
| |
| |
| public function isSingleSiteDayArchive() |
| { |
| return $this->isDayArchive() && $this->isSingleSite(); |
| } |
|
|
| |
| |
| |
| public function isDayArchive() |
| { |
| $period = $this->getPeriod(); |
| $secondsInPeriod = $period->getDateEnd()->getTimestampUTC() - $period->getDateStart()->getTimestampUTC(); |
| $oneDay = $secondsInPeriod < Date::NUM_SECONDS_IN_DAY; |
|
|
| return $oneDay; |
| } |
|
|
| public function isSingleSite() |
| { |
| return count($this->getIdSites()) == 1; |
| } |
|
|
| public function logStatusDebug() |
| { |
| $temporary = 'definitive archive'; |
| Log::debug( |
| "%s archive, idSite = %d (%s), segment '%s', plugin = '%s', report = '%s', UTC datetime [%s -> %s]", |
| $this->getPeriod()->getLabel(), |
| $this->getSite()->getId(), |
| $temporary, |
| $this->getSegment()->getString(), |
| $this->getRequestedPlugin(), |
| $this->getArchiveOnlyReport(), |
| $this->getDateStart()->getDateStartUTC(), |
| $this->getDateEnd()->getDateEndUTC() |
| ); |
| } |
|
|
| public function __toString() |
| { |
| $requestedReports = $this->getArchiveOnlyReport(); |
| if (is_array($requestedReports)) { |
| $requestedReports = implode(', ', $requestedReports); |
| } |
| return "[idSite = {$this->getSite()->getId()}, period = {$this->getPeriod()->getLabel()} {$this->getPeriod()->getRangeString()}, segment = {$this->getSegment()->getString()}, plugin = {$this->getRequestedPlugin()}, report = {$requestedReports}]"; |
| } |
|
|
| |
| |
| |
| |
| |
| public function isPartialArchive() |
| { |
| if (!$this->getRequestedPlugin()) { |
| return false; |
| } |
|
|
| if (!empty($this->getArchiveOnlyReport())) { |
| return true; |
| } |
|
|
| return $this->isArchiveOnlyReportHandled; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| public function setIsPartialArchive($isArchiveOnlyReportHandled) |
| { |
| $this->isArchiveOnlyReportHandled = $isArchiveOnlyReportHandled; |
| } |
|
|
| public function getArchiveOnlyReportAsArray() |
| { |
| $requestedReport = $this->getArchiveOnlyReport(); |
| if (empty($requestedReport)) { |
| return []; |
| } |
| return is_array($requestedReport) ? $requestedReport : [$requestedReport]; |
| } |
|
|
| public function setFoundRequestedReports(array $foundRecords) |
| { |
| $this->foundRequestedReports = $foundRecords; |
| } |
|
|
| public function getFoundRequestedReports() |
| { |
| return $this->foundRequestedReports ?: []; |
| } |
| } |
|
|