* Fix duplicate field in select list.

This commit is contained in:
qixinzhi
2023-09-28 06:08:51 +00:00
parent eda3acb72f
commit 9aa7ec8627
4 changed files with 47 additions and 10 deletions
@@ -30,17 +30,21 @@ class count_of_daily_finished_task_in_execution extends baseCalc
public function calculate($row)
{
if($row->status != 'done' || empty($row->finishedDate)) return false;
$status = $row->status;
$finishedDate = $row->finishedDate;
$execution = $row->execution;
if(empty($row->finishedDate)) return false;
$date = substr($row->finishedDate, 0, 10);
if($status != 'done' || empty($finishedDate)) return false;
if(empty($finishedDate)) return false;
$date = substr($finishedDate, 0, 10);
list($year, $month, $day) = explode('-', $date);
if($year == '0000') return false;
if(!isset($this->result[$row->execution])) $this->result[$row->execution] = array();
if(!isset($this->result[$row->execution][$year])) $this->result[$row->execution][$year] = array();
if(!isset($this->result[$row->execution][$year][$month])) $this->result[$row->execution][$year][$month] = array();
if(!isset($this->result[$row->execution][$year][$month][$day])) $this->result[$row->execution][$year][$month][$day] = 0;
if(!isset($this->result[$execution])) $this->result[$execution] = array();
if(!isset($this->result[$execution][$year])) $this->result[$execution][$year] = array();
if(!isset($this->result[$execution][$year][$month])) $this->result[$execution][$year][$month] = array();
if(!isset($this->result[$execution][$year][$month][$day])) $this->result[$execution][$year][$month][$day] = 0;
$this->result[$row->execution][$year][$month][$day] ++;
}
+4 -1
View File
@@ -681,7 +681,10 @@ window.renderCheckedLabel = function()
$content.append(html);
var $label = $content.find('[metric-id="' + label.id + '"]');
var labelWidth = Math.ceil($label.width() + parseInt($label.css('padding-left')) + parseInt($label.css('padding-right')) + parseInt($label.css('margin-left')) + parseInt($label.css('margin-right')));
var labelWidth = $label.width();
var labelLeft = parseInt($label.css('padding-left')) + parseInt($label.css('margin-left'));
var labelRight = parseInt($label.css('padding-right')) + parseInt($label.css('margin-right'));
var labelWidth = Math.ceil(labelWidth + labelLeft + labelRight);
left = left - labelWidth;
if(left <= 0)
+13 -1
View File
@@ -441,7 +441,19 @@ class metricModel extends model
{
$fieldList = array();
foreach($calcList as $calcInstance) $fieldList = array_merge($fieldList, $calcInstance->fieldList);
return implode(',', array_unique($fieldList));
$uniqueList = array_unique($fieldList);
$aliasList = array();
foreach($uniqueList as $field)
{
if(strpos($field, '.') === false)
{
$aliasList[] = $field;
continue;
}
$alias = str_replace('.', '_', $field);
$aliasList[] = $field . ' AS ' . $alias;
}
return implode(',', $aliasList);
}
/**
+19 -1
View File
@@ -224,11 +224,29 @@ class metricZen extends metric
{
foreach($calcList as $calc)
{
$calc->calculate((object)$row);
$record = $this->getCalcFields($calc, $row);
$calc->calculate($record);
}
}
}
protected function getCalcFields($calc, $row)
{
if(!isset($calc->dataset) || empty($calc->dataset)) return (object)$row;
$pureRow = new stdclass();
foreach($calc->fieldList as $field)
{
$extractField = explode('.', $field);
$pureField = end($extractField);
$aliasField = str_replace('.', '_', $field);
$pureRow->$pureField = $row->$aliasField;
}
return $pureRow;
}
/**
* 获取度量项的基本信息。
* Get the basic information of the metric.