From b0ebeb05a0492500c01530cc3f0486ab4f718280 Mon Sep 17 00:00:00 2001 From: dingguodong Date: Mon, 7 Aug 2023 15:08:07 +0800 Subject: [PATCH] * Refactor cronModel::getCrons, easy to filter crons. --- module/cron/model.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/module/cron/model.php b/module/cron/model.php index e01d59145d..a83167293d 100644 --- a/module/cron/model.php +++ b/module/cron/model.php @@ -32,14 +32,21 @@ class cronModel extends model */ public function getCrons($params = '') { - return $this->dao->select('*')->from(TABLE_CRON) - ->where('1=1') - ->beginIF(strpos($params, 'nostop') !== false)->andWhere('status')->ne('stop')->fi() - ->beginIF($this->config->edition != 'max') - ->andWhere('command')->ne('moduleName=measurement&methodName=initCrontabQueue') - ->andWhere('command')->ne('moduleName=measurement&methodName=execCrontabQueue') - ->fi() - ->fetchAll('id'); + $validCrons = $this->dao->select('*')->from(TABLE_CRON)->fetchAll('id'); + + $commandInMaxEdition = array( + 'moduleName=measurement&methodName=initCrontabQueue', + 'moduleName=measurement&methodName=execCrontabQueue', + 'moduleName=weekly&methodName=computeWeekly', + ); + foreach($validCrons as $id => $cron) + { + if(strpos($params, 'nostop') !== false and $cron->status == 'stop') unset($validCrons[$id]); + + if(in_array($cron->command, $commandInMaxEdition)) unset($validCrons[$id]); + } + + return $validCrons; } /**