Revert "Revert "* Fix metric scope order in config.""

This reverts commit a3132439dd.
This commit is contained in:
qixinzhi
2024-01-02 10:36:01 +08:00
parent 19fb631e0b
commit 372d04686c
3 changed files with 29 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
$config->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');
+7 -2
View File
@@ -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]);
+21
View File
@@ -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.