Revert "* Filter metric's data for screen designer."

This reverts commit 2174b5c232.
This commit is contained in:
qixinzhi
2023-12-18 10:52:58 +08:00
parent 11749117b7
commit fa7a08b9b1
2 changed files with 12 additions and 43 deletions
+8 -11
View File
@@ -171,23 +171,20 @@ class screen extends control
$mergeFilters[] = $filter;
}
if($type != 'metric')
if($table == TABLE_PIVOT)
{
if($table == TABLE_PIVOT)
{
list($sql, $filterFormat) = $this->loadModel($type)->getFilterFormat($chart->sql, $mergeFilters);
$chart->sql = $sql;
}
else
{
$filterFormat = $this->loadModel($type)->getFilterFormat($mergeFilters);
}
list($sql, $filterFormat) = $this->loadModel($type)->getFilterFormat($chart->sql, $mergeFilters);
$chart->sql = $sql;
}
else
{
$filterFormat = $this->loadModel($type)->getFilterFormat($mergeFilters);
}
}
if($type == 'metric')
{
$chartData = $this->screen->genMetricComponent($chart, null, $filterParams);
$chartData = $this->screen->genMetricComponent($chart);
}
else
{
+4 -32
View File
@@ -322,19 +322,17 @@ class screenModel extends model
* Generate metric component.
*
* @param object $metric
* @param object $component
* @param object $filterParams
* @access public
* @return object
*/
public function genMetricComponent($metric, $component = null, $filterParams = null)
public function genMetricComponent($metric, $component = null)
{
list($component, $typeChanged) = $this->initMetricComponent($metric, $component);
$component->chartConfig->title = $metric->name;
$component->chartConfig->sourceID = $metric->id;
$component->chartConfig->chartOption = $this->getMetricChartOption($metric);
$component->chartConfig->tableOption = $this->getMetricTableOption($metric, $filterParams);
$component->chartConfig->tableOption = $this->getMetricTableOption($metric);
$component->chartConfig->card = $this->getMetricCardOption($metric);
$component->chartConfig->filters = $this->buildMetricFilters($metric);
@@ -1659,11 +1657,10 @@ class screenModel extends model
* Get option of metric table.
*
* @param object $metric
* @param object $filterParams
* @access public
* @return object
*/
public function getMetricTableOption($metric, $filterParams = null)
public function getMetricTableOption($metric)
{
$this->loadModel('metric');
@@ -1677,7 +1674,7 @@ class screenModel extends model
$tableOption = new stdclass();
$tableOption->headers = $isObjectMetric ? $this->getMetricHeaders($groupHeader, $dateType) : array($groupHeader);
$tableOption->data = $this->filterMetricData($groupData, $filterParams);
$tableOption->data = $groupData;
if($metric->scope != 'system') $tableOption->objectPairs = $this->loadModel('metric')->getPairsByScope($metric->scope);
$tableOption->scope = $metric->scope;
@@ -1689,31 +1686,6 @@ class screenModel extends model
return $tableOption;
}
/**
* Filter metric data.
*
* @param array $data
* @param array $filter
* @access public
* @return array
*/
public function filterMetricData($data, $filters = null)
{
if(empty($filters)) return $data;
$objectPairs = $this->loadModel('metric')->getPairsByScope($filters[0]['field']);
$filteredData = array();
foreach($data as $row)
{
foreach($filters as $filter)
{
if($row['scope'] == $objectPairs[$filter['default']]) $filteredData[] = $row;
}
}
return $filteredData;
}
/**
* 获取度量项卡片参数。
* Get card option of metric.