* Modify method to get metric cycle.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user