Performance
1 year ago
ArchiveFilter.php
3 months ago
FixedSiteIds.php
3 months ago
QueueConsumer.php
7 months ago
ReArchiveList.php
1 year ago
SegmentArchiving.php
7 months ago
SharedSiteIds.php
3 months ago
StopArchiverException.php
2 years ago
FixedSiteIds.php
60 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Matomo - free/libre analytics platform |
| 5 | * |
| 6 | * @link https://matomo.org |
| 7 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 8 | */ |
| 9 | namespace Piwik\CronArchive; |
| 10 | |
| 11 | class FixedSiteIds |
| 12 | { |
| 13 | private $siteIds = array(); |
| 14 | private $index = -1; |
| 15 | public function __construct($websiteIds) |
| 16 | { |
| 17 | if (!empty($websiteIds)) { |
| 18 | $this->siteIds = array_values($websiteIds); |
| 19 | } |
| 20 | } |
| 21 | public function getInitialSiteIds() |
| 22 | { |
| 23 | return $this->siteIds; |
| 24 | } |
| 25 | /** |
| 26 | * Get the number of total websites that needs to be processed. |
| 27 | * |
| 28 | * @return int |
| 29 | */ |
| 30 | public function getNumSites() |
| 31 | { |
| 32 | return count($this->siteIds); |
| 33 | } |
| 34 | /** |
| 35 | * Get the number of already processed websites. All websites were processed by the current archiver. |
| 36 | * |
| 37 | * @return int |
| 38 | */ |
| 39 | public function getNumProcessedWebsites() |
| 40 | { |
| 41 | $numProcessed = $this->index + 1; |
| 42 | if ($numProcessed > $this->getNumSites()) { |
| 43 | return $this->getNumSites(); |
| 44 | } |
| 45 | return $numProcessed; |
| 46 | } |
| 47 | public function getNextSiteId() |
| 48 | { |
| 49 | $this->index++; |
| 50 | if (!empty($this->siteIds[$this->index])) { |
| 51 | return $this->siteIds[$this->index]; |
| 52 | } |
| 53 | return null; |
| 54 | } |
| 55 | public function isContinuingPreviousRun() : bool |
| 56 | { |
| 57 | return \false; |
| 58 | } |
| 59 | } |
| 60 |