diff options
author | diosmosis <benaka@piwik.pro> | 2015-03-05 05:25:18 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-03-05 05:25:18 +0300 |
commit | 5b96a6ecfe6bf42195b400daaca5331134f6ca87 (patch) | |
tree | 950e0b0888f84d17d6075b76e049b25b906e9c59 /core | |
parent | b92d60f9c30ef2c7ed06f43ac1dd5f29917a55ab (diff) |
Light refactoring to Archive\Purger class.
Diffstat (limited to 'core')
-rw-r--r-- | core/Archive/Purger.php | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/core/Archive/Purger.php b/core/Archive/Purger.php index d4e55993a9..34d0bc34be 100644 --- a/core/Archive/Purger.php +++ b/core/Archive/Purger.php @@ -35,13 +35,6 @@ class Purger private $model; /** - * TODO: what does this class even do? - * - * @var InvalidatedReports - */ - private $invalidatedReports; - - /** * TODO * * @var Date @@ -72,7 +65,6 @@ class Purger public function __construct(Model $model = null, Date $purgeCustomRangesOlderThan = null) { $this->model = $model ?: new Model(); - $this->invalidatedReports = new InvalidatedReports(); $this->purgeCustomRangesOlderThan = $purgeCustomRangesOlderThan ?: self::getDefaultCustomRangeToPurgeAgeThreshold(); @@ -86,9 +78,13 @@ class Purger */ public function purgeInvalidatedArchives() { - $idSitesByYearMonth = $this->invalidatedReports->getSitesByYearMonthArchiveToPurge(); + $invalidatedReports = new InvalidatedReports(); + + $idSitesByYearMonth = $invalidatedReports->getSitesByYearMonthArchiveToPurge(); foreach ($idSitesByYearMonth as $yearMonth => $idSites) { // TODO: change the option to store $yearMonths as values? perhaps not necessary right now $this->purgeInvalidatedArchivesFrom($yearMonth); + + $invalidatedReports->markSiteIdsHaveBeenPurged($idSites, $yearMonth); } } @@ -102,17 +98,18 @@ class Purger // we don't want to do an INNER JOIN on every row in a archive table that can potentially have tens to hundreds of thousands of rows, // so we first look for sites w/ invalidated archives, and use this as a constraint in getInvalidatedArchiveIdsSafeToDelete() below. - // the constraint will hit an INDEX and speed things up. + // the constraint will hit an INDEX and speed up the inner join that happens in getInvalidatedArchiveIdsSafeToDelete(). $idSites = $this->model->getSitesWithInvalidatedArchive($numericTable); + if (empty($idSites)) { + return; + } $archiveIds = $this->model->getInvalidatedArchiveIdsSafeToDelete($numericTable, $idSites); - if (count($archiveIds) == 0) { + if (empty($archiveIds)) { return; } $this->deleteArchiveIds($date, $archiveIds); - - $this->invalidatedReports->markSiteIdsHaveBeenPurged($idSites, $yearMonth); } /** |