mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
Merge branch '1522-Fallos_a_la_hora_de_representar_las_gráficas_con_rangos_en_desconocido_v714_2' into 'develop'
fixed errors in TIP See merge request artica/pandorafms!1045
This commit is contained in:
commit
a38f47b4a9
@ -481,9 +481,6 @@ function db_get_all_rows_sql($sql, $search_history_db = false, $cache = true, $d
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Returns the time the module is in unknown status (by events)
|
* Returns the time the module is in unknown status (by events)
|
||||||
@ -514,7 +511,6 @@ function db_get_module_ranges_unknown($id_agente_modulo, $tstart = false, $tend
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Retrieve going unknown events in range
|
// Retrieve going unknown events in range
|
||||||
$query = "SELECT utimestamp,event_type FROM tevento WHERE id_agentmodule = " . $id_agente_modulo;
|
$query = "SELECT utimestamp,event_type FROM tevento WHERE id_agentmodule = " . $id_agente_modulo;
|
||||||
$query .= " AND event_type like 'going_%' ";
|
$query .= " AND event_type like 'going_%' ";
|
||||||
@ -527,7 +523,7 @@ function db_get_module_ranges_unknown($id_agente_modulo, $tstart = false, $tend
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$last_status = 0; // normal
|
$last_status = $events[0]["event_type"] != "going_unknown" ? 1:0;
|
||||||
$return = array();
|
$return = array();
|
||||||
$i=0;
|
$i=0;
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
@ -555,6 +551,9 @@ function db_get_module_ranges_unknown($id_agente_modulo, $tstart = false, $tend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!isset($return[0])){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
@ -573,6 +572,16 @@ function db_get_module_ranges_unknown($id_agente_modulo, $tstart = false, $tend
|
|||||||
*
|
*
|
||||||
* Note: All "unknown" data are marked as NULL
|
* Note: All "unknown" data are marked as NULL
|
||||||
* Warning: Be careful with the amount of data, check your RAM size available
|
* Warning: Be careful with the amount of data, check your RAM size available
|
||||||
|
* We'll return a bidimensional array
|
||||||
|
* Structure returned: schema:
|
||||||
|
*
|
||||||
|
* uncompressed_data =>
|
||||||
|
* pool_id (int)
|
||||||
|
* utimestamp (start of current slice)
|
||||||
|
* data
|
||||||
|
* array
|
||||||
|
* datos
|
||||||
|
* utimestamp
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = false) {
|
function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = false) {
|
||||||
@ -619,6 +628,7 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
|
|||||||
$query .= " AND utimestamp=" . $first_utimestamp;
|
$query .= " AND utimestamp=" . $first_utimestamp;
|
||||||
|
|
||||||
$data = db_get_all_rows_sql($query,$search_historydb);
|
$data = db_get_all_rows_sql($query,$search_historydb);
|
||||||
|
|
||||||
if ($data === false) {
|
if ($data === false) {
|
||||||
// first utimestamp not found in active database
|
// first utimestamp not found in active database
|
||||||
// SEARCH HISTORY DB
|
// SEARCH HISTORY DB
|
||||||
@ -643,7 +653,9 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
|
|||||||
// Retrieve all data from module in given range
|
// Retrieve all data from module in given range
|
||||||
$raw_data = db_get_all_rows_sql($query, $search_historydb);
|
$raw_data = db_get_all_rows_sql($query, $search_historydb);
|
||||||
|
|
||||||
if (($raw_data === false) && ($first_utimestamp === $tstart)) {
|
$module_interval = modules_get_interval ($id_agente_modulo);
|
||||||
|
|
||||||
|
if (($raw_data === false) && ( ($first_utimestamp < $tstart - (SECONDS_1DAY + 2*$module_interval)) ) ) {
|
||||||
// No data
|
// No data
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -651,28 +663,45 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
|
|||||||
// Retrieve going unknown events in range
|
// Retrieve going unknown events in range
|
||||||
$unknown_events = db_get_module_ranges_unknown($id_agente_modulo, $tstart, $tend, $search_historydb);
|
$unknown_events = db_get_module_ranges_unknown($id_agente_modulo, $tstart, $tend, $search_historydb);
|
||||||
|
|
||||||
// Retrieve module_interval to build the template
|
$previous_unknown_events = db_get_module_ranges_unknown(
|
||||||
$module_interval = modules_get_interval ($id_agente_modulo);
|
$id_agente_modulo,
|
||||||
$slice_size = $module_interval;
|
$tstart - (SECONDS_1DAY + 2*$module_interval),
|
||||||
|
$tstart,
|
||||||
|
$search_historydb
|
||||||
|
);
|
||||||
|
|
||||||
// We'll return a bidimensional array
|
//don't show graph if graph is inside unknown
|
||||||
// Structure returned: schema:
|
if( $previous_unknown_events &&
|
||||||
//
|
!isset($previous_unknown_events[count($previous_unknown_events) -1]['time_to']) &&
|
||||||
// uncompressed_data =>
|
$unknown_events === false && $raw_data === false){
|
||||||
// pool_id (int)
|
return false;
|
||||||
// utimestamp (start of current slice)
|
}
|
||||||
// data
|
|
||||||
// array
|
//if time to is missing in last event force time to outside range time
|
||||||
// utimestamp
|
if( $unknown_events && !isset($unknown_events[count($unknown_events) -1]['time_to']) ){
|
||||||
// datos
|
$unknown_events[count($unknown_events) -1]['time_to'] = $tend + $module_interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if time to is missing in first event force time to outside range time
|
||||||
|
if ($first_data["datos"] === false) {
|
||||||
|
$last_inserted_value = false;
|
||||||
|
}elseif( $unknown_events && !isset($unknown_events[0]['time_from']) ||
|
||||||
|
$first_utimestamp < $tstart - (SECONDS_1DAY + 2*$module_interval) ){
|
||||||
|
$last_inserted_value = null;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$last_inserted_value = $first_data["datos"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve module_interval to build the template
|
||||||
|
$slice_size = $module_interval;
|
||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
|
|
||||||
// Point current_timestamp to begin of the set and initialize flags
|
// Point current_timestamp to begin of the set and initialize flags
|
||||||
$current_timestamp = $tstart;
|
$current_timestamp = $tstart;
|
||||||
$last_inserted_value = $first_data["datos"];
|
|
||||||
$last_timestamp = $first_data["utimestamp"];
|
$last_timestamp = $first_data["utimestamp"];
|
||||||
$last_value = $first_data["datos"];
|
$last_value = $first_data["datos"];
|
||||||
|
|
||||||
// Build template
|
// Build template
|
||||||
$pool_id = 0;
|
$pool_id = 0;
|
||||||
@ -732,7 +761,7 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
|
|||||||
($current_timestamp_end >= $current_unknown['time_from']) ) ||
|
($current_timestamp_end >= $current_unknown['time_from']) ) ||
|
||||||
($current_timestamp_end >= $current_unknown['time_to']) ) ) {
|
($current_timestamp_end >= $current_unknown['time_to']) ) ) {
|
||||||
|
|
||||||
if( ( $current_timestamp < $current_unknown['time_from']) &&
|
if( ( $current_timestamp <= $current_unknown['time_from']) &&
|
||||||
( $current_timestamp_end >= $current_unknown['time_from'] ) ){
|
( $current_timestamp_end >= $current_unknown['time_from'] ) ){
|
||||||
// Add unknown state detected
|
// Add unknown state detected
|
||||||
$tmp_data["utimestamp"] = $current_unknown["time_from"];
|
$tmp_data["utimestamp"] = $current_unknown["time_from"];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user