Historic string data separated from normal data

This commit is contained in:
Calvo 2022-09-08 14:28:36 +02:00
parent 3524cdac6c
commit 30ffe64abc
2 changed files with 23 additions and 1 deletions

View File

@ -1570,6 +1570,18 @@ function config_update_config()
$error_update[] = __('Days');
}
if (config_update_value('history_db_adv', get_parameter_switch('history_db_adv', 0), true) === false) {
$error_update[] = __('Enable history database advanced');
}
$history_db_string_days = get_parameter('history_db_string_days');
if (is_numeric($history_db_string_days) === false
|| $history_db_string_days <= 0
|| config_update_value('history_db_string_days', $history_db_string_days) === false
) {
$error_update[] = __('String Days');
}
$history_event_days = get_parameter('history_event_days');
if (is_numeric($history_event_days) === false
|| $history_event_days <= 0
@ -2500,6 +2512,14 @@ function config_process_config()
config_update_value('history_db_days', 0);
}
if (!isset($config['history_db_adv'])) {
config_update_value('history_db_adv', false);
}
if (!isset($config['history_db_string_days'])) {
config_update_value('history_db_string_days', 0);
}
if (!isset($config['history_event_days'])) {
config_update_value('history_event_days', 90);
}

View File

@ -644,6 +644,8 @@ sub pandora_load_config_pdb ($) {
$conf->{'_history_db_user'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_user'");
$conf->{'_history_db_pass'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_pass'");
$conf->{'_history_db_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_days'");
$conf->{'_history_db_adv'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_adv'");
$conf->{'_history_db_string_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_string_days'");
$conf->{'_history_event_days'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_event_days'");
$conf->{'_history_db_step'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_step'");
$conf->{'_history_db_delay'} = get_db_value ($dbh, "SELECT value FROM tconfig WHERE token = 'history_db_delay'");
@ -1128,7 +1130,7 @@ sub pandoradb_main ($$$;$) {
# Move old data to the history DB
if (defined ($history_dbh)) {
undef ($history_dbh) unless defined (enterprise_hook ('pandora_historydb', [$dbh, $history_dbh, $conf->{'_history_db_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}]));
undef ($history_dbh) unless defined (enterprise_hook ('pandora_historydb', [$dbh, $history_dbh, $conf->{'_history_db_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}, $conf->{'_history_db_string_days'}, $conf->{'_history_db_adv'}]));
if (defined($conf{'_history_event_enabled'}) && $conf->{'_history_event_enabled'} ne "" && $conf->{'_history_event_enabled'} == 1) {
undef ($history_dbh) unless defined (enterprise_hook ('pandora_history_event', [$dbh, $history_dbh, $conf->{'_history_event_days'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}]));
}