From d49c5e4954336fa79371fc7eb6a8e965bd4d6641 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 13 Nov 2023 15:12:55 +0100 Subject: [PATCH] delete agents pandora_db pandora_enterprise#12293 --- pandora_server/util/pandora_db.pl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 92c6c5f9ce..b68e71c469 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -142,10 +142,18 @@ sub pandora_purgedb ($$$) { # Delete manually disabled agents after some period if (defined ($conf->{'_delete_disabled_agents'}) && $conf->{'_delete_disabled_agents'} > 0) { log_message('PURGE', "Deleting old disabled agents (More than " . $conf->{'_delete_disabled_agents'} . " days)."); - db_do ($dbh, "DELETE FROM tagente - WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW()) - AND disabled = 1 - AND modo != 2", $conf->{'_delete_disabled_agents'} * 8600); + my @agents_to_delete = get_db_rows ( + $dbh, + "SELECT id_agente FROM tagente + WHERE UNIX_TIMESTAMP(ultimo_contacto) + ? < UNIX_TIMESTAMP(NOW()) + AND disabled = 1 + AND modo != 2", + $conf->{'_delete_disabled_agents'} * 8600 + ); + + foreach my $agent_to_delete (@agents_to_delete) { + pandora_delete_agent($dbh, $agent_to_delete->{'id_agente'}); + } } # Delete old data