From abd45be76d31e433187152195dd28b78cbd3f756 Mon Sep 17 00:00:00 2001 From: liugang Date: Fri, 18 Apr 2025 10:28:21 +0800 Subject: [PATCH] * [refac] reuse the processRows method of chartTao. --- module/bi/model.php | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/module/bi/model.php b/module/bi/model.php index 93b267d3f9..0d8234e722 100644 --- a/module/bi/model.php +++ b/module/bi/model.php @@ -693,7 +693,7 @@ class biModel extends model } $sql .= " group by $groupBySql"; $rows = $this->queryWithDriver($driver, $sql); - $stat = $this->processRows($rows, $date, $group, $metric); + $stat = $this->chart->processRows($rows, $date, $group, $metric); $maxCount = 50; if($sort) arsort($stat); @@ -766,49 +766,6 @@ class biModel extends model return $menu; } - /** - * Process rows. - * - * @param array $rows - * @param string $date - * @param string $group - * @param string $metric - * @access public - * @return array - */ - public function processRows($rows, $date, $group, $metric) - { - $this->loadModel('chart'); - - $stat = array(); - foreach($rows as $row) - { - if(!empty($date) and $date == 'MONTH') - { - $stat[sprintf("%04d", $row->ttyear) . '-' . sprintf("%02d", $row->ttgroup)] = $row->$metric; - } - elseif(!empty($date) and $date == 'YEARWEEK') - { - $yearweek = sprintf("%06d", $row->$group); - $year = substr($yearweek, 0, strlen($yearweek) - 2); - $week = substr($yearweek, -2); - - $weekIndex = in_array($this->app->getClientLang(), array('zh-cn', 'zh-tw')) ? sprintf($this->lang->chart->groupWeek, $year, $week) : sprintf($this->lang->chart->groupWeek, $week, $year); - $stat[$weekIndex] = $row->$metric; - } - elseif(!empty($date) and $date == 'YEAR') - { - $stat[sprintf("%04d", $row->$group)] = $row->$metric; - } - else - { - $stat[$row->$group] = $row->$metric; - } - } - - return $stat; - } - /* * 准备内置的图表sql语句。 * Prepare builtin chart sql.