diff --git a/module/metric/config.php b/module/metric/config.php index d6e9b6f621..65c570e2ab 100644 --- a/module/metric/config.php +++ b/module/metric/config.php @@ -1,6 +1,6 @@ metric = new stdclass(); -$config->metric->scopeList = array('system', 'program', 'project', 'execution', 'product', 'user', 'dept'); +$config->metric->scopeList = array('system', 'program', 'product', 'project', 'execution', 'dept', 'user', 'code', 'pipeline'); $config->metric->objectList = array('program', 'line', 'product', 'project', 'productplan', 'execution', 'release', 'story', 'requirement', 'task', 'bug', 'case', 'user', 'effort', 'doc', 'feedback', 'risk', 'issue', 'review'); $config->metric->purposeList = array('scale', 'qc', 'hour', 'cost', 'rate', 'time'); $config->metric->dateList = array('year', 'month', 'week', 'day'); diff --git a/module/metric/model.php b/module/metric/model.php index c4707d24bd..c966c40f75 100755 --- a/module/metric/model.php +++ b/module/metric/model.php @@ -271,11 +271,16 @@ class metricModel extends model * @access public * @return array */ - public function getScopePairs() + public function getScopePairs($all = true) { $scopePairs = array(); foreach($this->config->metric->scopeList as $scope) { + if(!$all) + { + $metrics = $this->metricTao->fetchMetricsByScope($scope, 1); + if(empty($metrics)) continue; + } $scopePair = new stdclass(); $scopePair->value = $scope; $scopePair->label = $this->lang->metric->scopeList[$scope]; @@ -1086,7 +1091,7 @@ class metricModel extends model { foreach($this->lang->metric->scopeList as $scope => $name) { - $metrics = $this->metricTao->fetchMetrics($scope, $stage); + $metrics = $this->metricTao->fetchMetricsByScope($scope, 1); if(empty($metrics)) { unset($this->lang->metric->scopeList[$scope]); diff --git a/module/metric/tao.php b/module/metric/tao.php index d645f20c4b..8e792b4480 100644 --- a/module/metric/tao.php +++ b/module/metric/tao.php @@ -43,6 +43,27 @@ class metricTao extends metricModel return $metrics; } + /** + * 根据范围获取度量项。 + * Fetch metric by scope. + * + * @param string $scope + * @param int $limit + * @access protected + * @return array + */ + protected function fetchMetricsByScope($scope, $limit = -1) + { + $metrics = $this->dao->select('*')->from(TABLE_METRIC) + ->where('deleted')->eq('0') + ->andWhere('scope')->eq($scope) + ->andWhere('object')->in(array_keys($this->lang->metric->objectList)) + ->beginIF($limit > 0)->limit($limit)->fi() + ->fetchAll(); + + return $metrics; + } + /** * 根据编号获取度项。 * Fetch metric by id.