Last value report meta with date before

This commit is contained in:
Calvo 2022-02-02 10:32:46 +01:00
parent 83d490df5d
commit fd75b5360f
2 changed files with 25 additions and 14 deletions

View File

@ -1080,14 +1080,23 @@ function modules_get_agentmodule($id_agentmodule)
}
function modules_get_table_data($id_agent_module)
/**
* Gets data table for agent module
*
* @param integer|null $id_agent_module Id agentmodule.
* @param integer|null $id_type Id module type.
* @return void
*/
function modules_get_table_data(?int $id_agent_module, ?int $id_type)
{
$id_type = db_get_value(
'id_tipo_modulo',
'tagente_modulo',
'id_agente_modulo',
$id_agent_module
);
if ($id_type === null) {
$id_type = db_get_value(
'id_tipo_modulo',
'tagente_modulo',
'id_agente_modulo',
$id_agent_module
);
}
$name_type = db_get_value('nombre', 'ttipo_modulo', 'id_tipo', $id_type);

View File

@ -4148,16 +4148,17 @@ function reporting_last_value($report, $content, $datetime, $period)
$result = $module->getStatus()->toArray();
if ($result === false) {
$result = [];
$result['utimestamp'] = '-';
if ($result === false
|| $result['estado'] == AGENT_MODULE_STATUS_NO_DATA
|| $result['estado'] == AGENT_MODULE_STATUS_NOT_INIT
) {
$result['utimestamp'] = '';
$result['datos'] = __('No data to display within the selected interval');
}
if ($datetime < $result['utimestamp']) {
$table_data = modules_get_table_data($id_agent_module);
$init_date_condition = '';
$id_tipo_modulo = $module->id_tipo_modulo();
$table_data = modules_get_table_data(null, $id_tipo_modulo);
if ($period !== null) {
$sql = sprintf(
'SELECT datos, utimestamp FROM %s WHERE id_agente_modulo = %d AND utimestamp BETWEEN %d AND %d ORDER BY utimestamp DESC',
@ -4175,7 +4176,8 @@ function reporting_last_value($report, $content, $datetime, $period)
);
}
$datos = db_get_row_sql($sql);
$search_in_history_db = db_search_in_history_db($datelimit);
$datos = db_get_row_sql($sql, $search_in_history_db);
if ($datos !== false) {
$result['datos'] = $datos['datos'];
$result['utimestamp'] = $datos['utimestamp'];