From 5774c732ada9b361396c6eeac045672abb905a39 Mon Sep 17 00:00:00 2001 From: liugang Date: Tue, 30 Dec 2025 10:19:28 +0800 Subject: [PATCH] * [refac] Improve return types to bool. --- module/product/model.php | 13 ++++++++----- module/program/model.php | 14 ++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/module/product/model.php b/module/product/model.php index 8d44f68f93..5f163c810f 100755 --- a/module/product/model.php +++ b/module/product/model.php @@ -2083,13 +2083,12 @@ class productModel extends model * * @param bool $refreshAll * @access public - * @return void + * @return bool */ - public function refreshStats(bool $refreshAll = false): void + public function refreshStats(bool $refreshAll = false): bool { $updateTime = zget($this->app->config->global, 'productStatsTime', ''); - $now = helper::now(); - if($updateTime && time() - strtotime($updateTime) < $this->config->product->refreshInterval && !$refreshAll) return; + if($updateTime && time() - strtotime($updateTime) < $this->config->product->refreshInterval && !$refreshAll) return true; /* * If productStatsTime is before two weeks ago, refresh all products directly. @@ -2107,7 +2106,7 @@ class productModel extends model ->where('date')->ge($updateTime) ->andWhere('product')->notin(array(',0,', ',,')) ->fetchPairs('product'); - if(empty($productActions)) return; + if(empty($productActions)) return true; foreach($productActions as $productAction) { @@ -2115,6 +2114,8 @@ class productModel extends model } } + $now = helper::now(); + /* 1. Get summary of products to be refreshed. */ $stats = $this->productTao->getProductStats($products); @@ -2130,6 +2131,8 @@ class productModel extends model /* 4. Clear actions older than 30 days. */ $this->loadModel('action')->cleanActions(); + + return !dao::isError(); } /* diff --git a/module/program/model.php b/module/program/model.php index c9a7147b5f..514f7a8374 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1319,13 +1319,12 @@ class programModel extends model * * @param bool $refreshAll * @access public - * @return void + * @return bool */ - public function refreshStats($refreshAll = false): void + public function refreshStats($refreshAll = false): bool { $updateTime = zget($this->app->config->global, 'projectStatsTime', ''); - $now = helper::now(); - if($updateTime && time() - strtotime($updateTime) < $this->config->program->refreshInterval && !$refreshAll) return; + if($updateTime && time() - strtotime($updateTime) < $this->config->program->refreshInterval && !$refreshAll) return true; /* * If projectStatsTime is before two weeks ago, refresh all executions directly. @@ -1344,7 +1343,9 @@ class programModel extends model ->andWhere('t1.project')->ne(0) ->fetchAll('project'); } - if(empty($projects)) return; + if(empty($projects)) return true; + + $now = helper::now(); /* 1. Refresh stats to db. */ $this->programTao->updateStats(array_keys($projects)); @@ -1358,8 +1359,9 @@ class programModel extends model /* 4. Clear actions older than 30 days. */ $this->loadModel('action')->cleanActions(); - } + return !dao::isError(); + } /** * 刷新项目的统计数据。