Merge branch 'ent-8233-12588-Reports-Item-tipo-Increment-no-lee-datos-de-historico' into 'develop'

include historic db data in report

See merge request artica/pandorafms!4623
This commit is contained in:
Daniel Rodriguez 2022-01-12 09:41:59 +00:00
commit c04ebf42e4
5 changed files with 22 additions and 14 deletions

View File

@ -874,10 +874,10 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
*
* @return the first value of the first row of a table result from query.
*/
function mysql_db_get_value_sql($sql, $dbconnection=false)
function mysql_db_get_value_sql($sql, $dbconnection=false, $search_history_db=false)
{
$sql .= ' LIMIT 1';
$result = mysql_db_get_all_rows_sql($sql, false, true, $dbconnection);
$result = mysql_db_get_all_rows_sql($sql, $search_history_db, true, $dbconnection);
if ($result === false) {
return false;

View File

@ -977,10 +977,10 @@ function oracle_recode_query($sql, $values, $join='AND', $return=true)
*
* @return the first value of the first row of a table result from query.
*/
function oracle_db_get_value_sql($sql, $dbconnection=false)
function oracle_db_get_value_sql($sql, $dbconnection=false, $search_history_db=false)
{
$sql = 'SELECT * FROM ('.$sql.') WHERE rownum < 2';
$result = oracle_db_get_all_rows_sql($sql, false, true, $dbconnection);
$result = oracle_db_get_all_rows_sql($sql, $search_history_db, true, $dbconnection);
if ($result === false) {
return false;

View File

@ -686,10 +686,10 @@ function postgresql_db_format_array_where_clause_sql($values, $join='AND', $pref
*
* @return the first value of the first row of a table result from query.
*/
function postgresql_db_get_value_sql($sql, $dbconnection=false)
function postgresql_db_get_value_sql($sql, $dbconnection=false, $search_history_db=false)
{
$sql .= ' LIMIT 1';
$result = postgresql_db_get_all_rows_sql($sql, false, true, $dbconnection);
$result = postgresql_db_get_all_rows_sql($sql, $search_history_db, true, $dbconnection);
if ($result === false) {
return false;

View File

@ -414,21 +414,21 @@ function db_get_value_filter($field, $table, $filter, $where_join='AND', $search
*
* @return mixed the first value of the first row of a table result from query.
*/
function db_get_value_sql($sql, $dbconnection=false)
function db_get_value_sql($sql, $dbconnection=false, $search_history_db=false)
{
global $config;
switch ($config['dbtype']) {
case 'mysql':
return mysql_db_get_value_sql($sql, $dbconnection);
return mysql_db_get_value_sql($sql, $dbconnection, $search_history_db);
break;
case 'postgresql':
return postgresql_db_get_value_sql($sql, $dbconnection);
return postgresql_db_get_value_sql($sql, $dbconnection, $search_history_db);
break;
case 'oracle':
return oracle_db_get_value_sql($sql, $dbconnection);
return oracle_db_get_value_sql($sql, $dbconnection, $search_history_db);
break;
}

View File

@ -8775,6 +8775,8 @@ function reporting_increment($report, $content)
$return['data'] = [];
$search_in_history_db = db_search_in_history_db($return['from']);
if (is_metaconsole()) {
$sql1 = 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.'
AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC';
@ -8801,17 +8803,23 @@ function reporting_increment($report, $content)
$connection = false;
}
$old_data = db_get_value_sql($sql1);
$old_data = db_get_value_sql($sql1, false, $search_in_history_db);
$last_data = db_get_value_sql($sql2);
$last_data = db_get_value_sql($sql2, false, $search_in_history_db);
}
} else {
$old_data = db_get_value_sql(
'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.'
AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC'
AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC',
false,
$search_in_history_db
);
$last_data = db_get_value_sql('SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' ORDER BY utimestamp DESC');
$last_data = db_get_value_sql(
'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' ORDER BY utimestamp DESC',
false,
$search_in_history_db
);
}
if (!is_metaconsole()) {