From 055518d344d216ac58b01e375b01ed5cbe91c358 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 28 Aug 2023 14:49:27 +0800 Subject: [PATCH] * Refactor getDateList method. --- module/api/v1/entries/execution.php | 2 +- module/execution/model.php | 17 +++++------ module/execution/test/execution.class.php | 11 ++++---- module/execution/test/model/getdatelist.php | 31 ++++++++++----------- 4 files changed, 31 insertions(+), 30 deletions(-) diff --git a/module/api/v1/entries/execution.php b/module/api/v1/entries/execution.php index 384f4254f8..d1bd8c8894 100644 --- a/module/api/v1/entries/execution.php +++ b/module/api/v1/entries/execution.php @@ -99,7 +99,7 @@ class executionEntry extends entry $execution->dynamics = $this->loadModel('action')->processDynamicForAPI($dynamics); break; case 'chartdata': - list($dateList, $interval) = $this->loadModel('execution')->getDateList($execution->begin, $execution->end, 'noweekend', '0', 'Y-m-d'); + list($dateList, $interval) = $this->loadModel('execution')->getDateList($execution->begin, $execution->end, 'noweekend', 0, 'Y-m-d'); $execution->chartData = $this->execution->buildBurnData($executionID, $dateList, 'left'); break; } diff --git a/module/execution/model.php b/module/execution/model.php index 0789c2cadd..059745a82c 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4381,18 +4381,19 @@ class executionModel extends model } /** - * Get no weekend date + * 获取日期列表数据。 + * Get date list data. * - * @param string $begin - * @param string $end - * @param string $type - * @param string|int $interval - * @param string $format - * @param string $executionDeadline + * @param string $begin + * @param string $end + * @param string $type + * @param int $interval + * @param string $format + * @param string $executionDeadline * @access public * @return array */ - public function getDateList($begin, $end, $type, $interval = '', $format = 'm/d/Y', $executionDeadline = '') + public function getDateList(string $begin, string $end, string $type, int $interval = 0, string $format = 'm/d/Y', string $executionDeadline = ''): array { $this->app->loadClass('date', true); $dateList = date::getDateList($begin, $end, $format, $type, $this->config->execution->weekend); diff --git a/module/execution/test/execution.class.php b/module/execution/test/execution.class.php index a224629bb0..9014d35666 100644 --- a/module/execution/test/execution.class.php +++ b/module/execution/test/execution.class.php @@ -2047,17 +2047,18 @@ class executionTest } /** - * function getDateList test by execution + * 获取日期列表数据。 + * Get date list data. * * @param string $begin * @param string $end * @param string $type - * @param string $count - * @param int $interval + * @param int $count + * @param int $interval * @access public - * @return array + * @return array|string|int */ - public function getDateListTest($begin, $end, $type, $count, $interval = 0) + public function getDateListTest(string $begin, string $end, string $type, int $count, int $interval = 0): array|string|int { $object = $this->executionModel->getDateList($begin, $end, $type, $interval); diff --git a/module/execution/test/model/getdatelist.php b/module/execution/test/model/getdatelist.php index 326a06b03b..131812f532 100755 --- a/module/execution/test/model/getdatelist.php +++ b/module/execution/test/model/getdatelist.php @@ -7,25 +7,24 @@ su('admin'); /** title=测试executionModel->getDateListTest(); +timeout=0 cid=1 -pid=1 - -去除工作日日期列表 >> 01/03/2022 -去除工作日日期列表统计 >> 5 -未去除工作日日期列表 >> 01/01/2022 -未去除工作日日期列表统计 >> 7 -日期输入错误查询 >> 无数据 */ -$start = array('2022-01-01', '2025-01-01'); -$end = array('2022-01-07', '2025-01-07'); -$count = array('0', '1'); -$type = array('noweekend', 'week'); +$start = array('2022-01-01', '2025-01-01'); +$end = array('2022-01-07', '2025-01-07'); +$count = array(0, 1); +$type = array('noweekend', 'week'); +$interval = array(1, 7); $execution = new executionTest(); -r($execution->getDateListTest($start[0], $end[0], $type[0] ,$count[0])) && p('0:0') && e('01/03/2022'); // 去除工作日日期列表 -r($execution->getDateListTest($start[0], $end[0], $type[0] ,$count[1])) && p() && e('5'); // 去除工作日日期列表统计 -r($execution->getDateListTest($start[0], $end[0], $type[1] ,$count[0])) && p('0:0') && e('01/01/2022'); // 未去除工作日日期列表 -r($execution->getDateListTest($start[0], $end[0], $type[1] ,$count[1])) && p() && e('7'); // 未去除工作日日期列表统计 -r($execution->getDateListTest($start[1], $end[0], $type[1] ,$count[0])) && p() && e('无数据'); // 日期输入错误查询 +r($execution->getDateListTest($start[0], $end[0], $type[0] ,$count[0])) && p('0:0') && e('01/03/2022'); // 去除工作日日期列表 +r($execution->getDateListTest($start[0], $end[0], $type[0] ,$count[1])) && p() && e('5'); // 去除工作日日期列表统计 +r($execution->getDateListTest($start[0], $end[0], $type[1] ,$count[0])) && p('0:0') && e('01/01/2022'); // 未去除工作日日期列表 +r($execution->getDateListTest($start[0], $end[0], $type[1] ,$count[1])) && p() && e('7'); // 未去除工作日日期列表统计 +r($execution->getDateListTest($start[1], $end[0], $type[1] ,$count[0])) && p() && e('无数据'); // 日期输入错误查询 +r($execution->getDateListTest($start[0], $end[0], $type[0] ,$count[0])) && p('0:0') && e('01/03/2022'); // 去除工作日日期列表 +r($execution->getDateListTest($start[0], $end[0], $type[0] ,$count[1], $interval[0])) && p() && e('3'); // 去除工作日日期间隔1天列表统计 +r($execution->getDateListTest($start[0], $end[0], $type[1] ,$count[0], $interval[1])) && p('0:0') && e('01/01/2022'); // 未去除工作日间隔2天日期列表 +r($execution->getDateListTest($start[0], $end[0], $type[1] ,$count[1], $interval[1])) && p() && e('1'); // 未去除工作日间隔2天日期列表统计