Skip to content

Commit

Permalink
Merge pull request #595 from directman66/patch-10
Browse files Browse the repository at this point in the history
Update objects.class.php
  • Loading branch information
sergejey committed Aug 15, 2019
2 parents 88e81da + 18cd932 commit 8ea3b84
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/objects.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,25 @@ function getHistory($varname, $start_time, $stop_time = 0)
return SQLSelect("SELECT VALUE, ADDED FROM $table_name WHERE VALUE_ID='" . $id . "' AND ADDED>=('" . date('Y-m-d H:i:s', $start_time) . "') AND ADDED<=('" . date('Y-m-d H:i:s', $stop_time) . "') ORDER BY ADDED");
}

function getHistoryAvgDay($varname, $start_time, $stop_time = 0)
{
if ($start_time <= 0) $start_time = (time() + $start_time);
if ($stop_time <= 0) $stop_time = (time() + $stop_time);

// Get hist val id
$id = getHistoryValueId($varname);

if (defined('SEPARATE_HISTORY_STORAGE') && SEPARATE_HISTORY_STORAGE == 1) {
$table_name = createHistoryTable($id);
} else {
$table_name = 'phistory';
}

// Get data
return SQLSelect("SELECT round(avg(VALUE),2) VALUE, date(ADDED) ADDED FROM $table_name WHERE VALUE_ID='" . $id . "' AND ADDED>=('" . date('Y-m-d H:i:s', $start_time) . "') AND ADDED<=('" . date('Y-m-d H:i:s', $stop_time) . "') group by date(ADDED) ORDER BY ADDED");
}


/**
* getHistoryMin
*
Expand Down Expand Up @@ -1362,4 +1381,4 @@ function addToOperationsQueue($topic, $dataname, $datavalue = '', $uniq = false,
$rec['ID'] = SQLInsert('operations_queue', $rec);
SQLExec("DELETE FROM operations_queue WHERE EXPIRE<NOW();");
return $rec['ID'];
}
}

0 comments on commit 8ea3b84

Please sign in to comment.