* Modify method to get metric cycle.

This commit is contained in:
zhouxin
2023-11-23 09:47:09 +08:00
parent 8451008e87
commit 10ea676b86
2 changed files with 10 additions and 8 deletions
+8 -7
View File
@@ -1486,18 +1486,19 @@ class metricModel extends model
* 获取度量项的收集周期。
* Get collect cycle of metric.
*
* @param array $results
* @param array|object $record
* @access public
* @return string|null
*/
public function getMetricCycle($results)
public function getMetricCycle($record)
{
$firstRecord = (object)current($results);
$record = (object)$record;
if(isset($record->year) && !isset($record->month) && !isset($record->week)) return 'year';
if(isset($record->year, $record->month) && !isset($record->day)) return 'month';
if(isset($record->year, $record->month, $record->day)) return 'day';
if(isset($record->year, $record->week)) return 'week';
foreach($this->config->metric->dateList as $date)
{
if(isset($firstRecord->$date)) return $date;
}
return null;
}
}
+2 -1
View File
@@ -188,7 +188,8 @@ class metricZen extends metric
$system = (int)$this->metric->isSystemMetric($results);
$cycle = $this->metric->getMetricCycle($results);
$firstRecord = (object)current($results);
$cycle = $this->metric->getMetricCycle($firstRecord);
$this->metric->clearOutDatedRecords($code, $cycle);
foreach($results as $record)