]> git.proxmox.com Git - pmg-api.git/commitdiff
PMG::DBTools::get_quarantine_count - new helper
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 24 Aug 2017 05:00:19 +0000 (07:00 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 24 Aug 2017 05:00:19 +0000 (07:00 +0200)
PMG/CLI/pmgreport.pm
PMG/DBTools.pm

index 91c0e59fc5326307df2a967026f84b705806820b..c41de8ca98337e4b445fb5b127b19003fb4a92b8 100644 (file)
@@ -18,6 +18,7 @@ use PMG::ClusterConfig;
 use PMG::Cluster;
 use PMG::API2::Cluster;
 use PMG::RuleDB;
+use PMG::DBTools;
 use PMG::Statistic;
 
 use base qw(PVE::CLIHandler);
@@ -194,21 +195,7 @@ my $get_virus_table_data = sub {
 my $get_quarantine_table_data = sub {
     my ($dbh, $qtype) = @_;
 
-    # Note;: We try to estimate used disk space - each mail
-    # is stored in an extra file ...
-
-    my $bs = 4096;
-
-    my $sth = $dbh->prepare(
-       "SELECT count(ID) as count,  sum (ceil((Bytes+$bs-1)/$bs)*$bs) / (1024*1024) as mbytes, " .
-       "avg(Bytes) as avgbytes, avg(Spamlevel) as avgspam " .
-       "FROM CMailStore WHERE QType = ?");
-
-    $sth->execute($qtype);
-
-    my $ref = $sth->fetchrow_hashref();
-
-    $sth->finish;
+    my $ref = PMG::DBTools::get_quarantine_count($dbh, $qtype);
 
     return undef if !($ref && $ref->{count});
 
index bac9006ef79704eb5ad56636126faf970794a7c2..45e436e8770940a764cc7965bb1b4dcb8f0188eb 100644 (file)
@@ -895,6 +895,28 @@ sub purge_quarantine_database {
     return $count;
 }
 
+sub get_quarantine_count {
+    my ($dbh, $qtype) = @_;
+
+    # Note;: We try to estimate used disk space - each mail
+    # is stored in an extra file ...
+
+    my $bs = 4096;
+
+    my $sth = $dbh->prepare(
+       "SELECT count(ID) as count,  sum (ceil((Bytes+$bs-1)/$bs)*$bs) / (1024*1024) as mbytes, " .
+       "avg(Bytes) as avgbytes, avg(Spamlevel) as avgspam " .
+       "FROM CMailStore WHERE QType = ?");
+
+    $sth->execute($qtype);
+
+    my $ref = $sth->fetchrow_hashref();
+
+    $sth->finish;
+
+    return $ref;
+}
+
 sub copy_table {
     my ($ldb, $rdb, $table) = @_;