Fix last value meta and status bug

This commit is contained in:
Calvo 2022-02-02 18:11:53 +01:00
parent fd75b5360f
commit 7fc62b4a2c
1 changed files with 14 additions and 3 deletions

View File

@ -4176,15 +4176,26 @@ function reporting_last_value($report, $content, $datetime, $period)
);
}
$search_in_history_db = db_search_in_history_db($datelimit);
$search_in_history_db = db_search_in_history_db($datetime);
try {
$module->connectNode();
} catch (\Exception $e) {
// Do not link items if failed to find them.
$module->restoreConnection();
}
$datos = db_get_row_sql($sql, $search_in_history_db);
// Restore if needed.
$module->restoreConnection();
if ($datos !== false) {
$result['datos'] = $datos['datos'];
$result['utimestamp'] = $datos['utimestamp'];
} else {
$result = [];
$result['utimestamp'] = '-';
$result['estado'] = AGENT_MODULE_STATUS_NO_DATA;
$result['datos'] = __('No data to display within the selected interval');
}
}