* Adjust code of updateMetricLib.
This commit is contained in:
@@ -2074,11 +2074,12 @@ class metricModel extends model
|
||||
* 根据日期类型和日期,拆解出日期的年、月、周、日。
|
||||
* Get date values by date type and date.
|
||||
*
|
||||
* @param string $date
|
||||
* @param string $date
|
||||
* @param string $dateType
|
||||
* @access public
|
||||
* @return object
|
||||
* @return object|array
|
||||
*/
|
||||
public function generateDateValues($date)
|
||||
public function parseDateStr($date, $dateType = 'all')
|
||||
{
|
||||
$timestamp = strtotime($date);
|
||||
|
||||
@@ -2089,14 +2090,13 @@ class metricModel extends model
|
||||
$week = substr($week, -2);
|
||||
|
||||
$dateValues = new stdClass();
|
||||
|
||||
$dateValues->year = array('year' => $year);
|
||||
$dateValues->month = array('year' => $year, 'month' => $month);
|
||||
$dateValues->week = array('year' => $year, 'week' => $week);
|
||||
$dateValues->day = array('year' => $year, 'month' => $month, 'day' => $day);
|
||||
$dateValues->nodate = array();
|
||||
|
||||
return $dateValues;
|
||||
return $dateType == 'all' ? $dateValues : $dateValues->$dateType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -182,20 +182,19 @@ class metricZen extends metric
|
||||
*/
|
||||
protected function prepareMetricRecord($calcList)
|
||||
{
|
||||
$yesterday = strtotime('-1 day', strtotime('today'));
|
||||
$yesterday = date('j', $yesterday);
|
||||
$yesterday = date('j', strtotime('-1 day', strtotime('today')));
|
||||
$today = date('j');
|
||||
$options = array('year' => date('Y'), 'month' => date('n'), 'week' => substr(date('oW'), -2), 'day' => "$today,$yesterday");
|
||||
|
||||
$now = helper::now();
|
||||
$dateValues = $this->metric->generateDateValues($now);
|
||||
$dateValues = $this->metric->parseDateStr($now);
|
||||
|
||||
$records = array();
|
||||
foreach($calcList as $code => $calc)
|
||||
{
|
||||
$metric = $this->metric->getByCode($code);
|
||||
$dateType = $this->metric->getDateTypeByCode($code);
|
||||
$recordCommon = $this->buildMetricRecordCommonFields($metric->id, $code, $now, $dateValues->$dateType);
|
||||
$recordCommon = $this->buildRecordCommonFields($metric->id, $code, $now, $dateValues->$dateType);
|
||||
$initRecords = $this->initMetricRecords($recordCommon, $metric->scope);
|
||||
|
||||
$results = $calc->getResult($options);
|
||||
@@ -277,7 +276,7 @@ class metricZen extends metric
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function buildMetricRecordCommonFields($metricID, $code, $date, $dateValues)
|
||||
protected function buildRecordCommonFields($metricID, $code, $date, $dateValues)
|
||||
{
|
||||
$record = new stdclass();
|
||||
$record->value = 0;
|
||||
|
||||
Reference in New Issue
Block a user