diff --git a/module/action/model.php b/module/action/model.php index 185df24ee8..a2c090491f 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -1333,8 +1333,6 @@ class actionModel extends model */ public function getDynamic($account = 'all', $period = 'all', $orderBy = 'date_desc', $limit = 50, $productID = 'all', $projectID = 'all', $executionID = 'all', $date = '', $direction = 'next') { - $this->cleanActions(); - /* Computer the begin and end date of a period. */ $beginAndEnd = $this->computeBeginAndEnd($period); extract($beginAndEnd); @@ -2665,10 +2663,16 @@ class actionModel extends model * Clear dynamic records older than one month. * * @access public - * @return void + * @return bool */ public function cleanActions() { + $cleanDate = zget($this->app->config->global, 'cleanActionsDate', ''); + $today = helper::today(); + if($cleanDate == $today) return true; + + $this->loadModel('setting')->setItem('system.common.global.cleanActionsDate', $today); + $lastMonth = date('Y-m-d', strtotime('-1 month')); $this->dao->delete()->from(TABLE_ACTIONRECENT)->where('date')->lt($lastMonth)->exec(); return !dao::isError(); diff --git a/module/product/model.php b/module/product/model.php index 303426a275..36d569f375 100755 --- a/module/product/model.php +++ b/module/product/model.php @@ -1905,6 +1905,9 @@ class productModel extends model /* 3. Update projectStatsTime in config. */ $this->loadModel('setting')->setItem('system.common.global.productStatsTime', $now); $this->app->config->global->productStatsTime = $now; + + /* 4. Clear actions older than 30 days. */ + $this->cleanActions(); } /** diff --git a/module/program/model.php b/module/program/model.php index 7a4827fb5c..a855cad5e3 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1424,6 +1424,9 @@ class programModel extends model /* 6. Update projectStatsTime in config. */ $this->loadModel('setting')->setItem('system.common.global.projectStatsTime', $now); $this->app->config->global->projectStatsTime = $now; + + /* 7. Clear actions older than 30 days. */ + $this->cleanActions(); } /**