diff --git a/config/global.ini.php b/config/global.ini.php index 56403829003ec7fd08e04e1978085705af8e623f..4820939bd3b4f31b5c509d31163d44fab2ab6a57 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -266,6 +266,11 @@ enable_browser_archiving_triggering = 1 ; so you can disable these special queries here: enable_sql_optimize_queries = 1 +; By default Piwik is purging complete date range archives to free spaces after deleting some data. +; If you are pre-processing custom ranges using CLI task to make them easily available in UI, +; you can prevent this action from happening by setting this parameter to value bigger than 1 +purge_date_range_archives_after_X_days = 1 + ; MySQL minimum required version ; note: timezone support added in 4.1.3 minimum_mysql_version = 4.1 diff --git a/core/DataAccess/ArchivePurger.php b/core/DataAccess/ArchivePurger.php index 7a961f99db0fbf2a5a011a2d2e1c0853431f2f2d..e7f185f4751d61e57dad2b3c7198237c6c8788ab 100644 --- a/core/DataAccess/ArchivePurger.php +++ b/core/DataAccess/ArchivePurger.php @@ -10,6 +10,7 @@ namespace Piwik\DataAccess; use Exception; use Piwik\ArchiveProcessor\Rules; +use Piwik\Config; use Piwik\Date; use Piwik\Db; use Piwik\Log; @@ -104,12 +105,13 @@ class ArchivePurger { $numericTable = ArchiveTableCreator::getNumericTable($date); $blobTable = ArchiveTableCreator::getBlobTable($date); - $yesterday = Date::factory('yesterday')->getDateTime(); + $daysRangesValid = Config::getInstance()->General['purge_date_range_archives_after_X_days']; + $pastDate = Date::factory('today')->subDay($daysRangesValid)->getDateTime(); - self::getModel()->deleteArchivesWithPeriod($numericTable, $blobTable, Piwik::$idPeriods['range'], $yesterday); + self::getModel()->deleteArchivesWithPeriod($numericTable, $blobTable, Piwik::$idPeriods['range'], $pastDate); Log::debug("Purging Custom Range archives: done [ purged archives older than %s from %s / blob ]", - $yesterday, $numericTable); + $pastDate, $numericTable); } /**