More enhancements to mapssrub
authorAndrew DeFaria <Andrew@DeFaria.com>
Sun, 18 Jul 2021 00:28:25 +0000 (17:28 -0700)
committerAndrew DeFaria <Andrew@DeFaria.com>
Sun, 18 Jul 2021 00:28:25 +0000 (17:28 -0700)
maps/bin/mapsscrub.pl
maps/lib/MAPS.pm

index d50b70f..2a0f54e 100755 (executable)
@@ -54,6 +54,7 @@ use Getopt::Long;
 use Pod::Usage;
 
 use DateUtils;
+use Display;
 use Logger;
 use MAPS;
 use Utils;
@@ -61,6 +62,8 @@ use Utils;
 my %opts = (
   usage    => sub { pod2usage },
   help     => sub { pod2usage (-verbose => 2)},
+  verbose  => sub { set_verbose },
+  debug    => sub { set_debug },
   optimize => 1,
 );
 
index e679d00..d63f9b9 100644 (file)
@@ -106,14 +106,14 @@ my $mapsbase = "$FindBin::Bin/..";
 sub _cleanTables($$;$) {
   my ($table, $timestamp, $dryrun) = @_;
 
-  my $count     = 0;
-  my $msg       = 'Records deleted';
   my $condition = "userid = '$userid' and timestamp < '$timestamp'";
 
   if ($dryrun) {
     return $db->count($table, $condition);
   } else {
-    return $db->delete($table, $condition);
+    my ($count, $msg) = $db->delete($table, $condition);
+
+    return $count;
   } # if
 } # _cleanTables
 
@@ -500,6 +500,7 @@ sub CleanList(%) {
   my $table     = 'list';
   my $condition = "userid='$params{userid}' and type='$params{type}'";
   my $count     = 0;
+  my $msg;
 
   # First let's go through the list to see if we have an domain level entry
   # (e.g. @spammer.com) and also individual entries (baddude@spammer.com) then
@@ -536,11 +537,12 @@ sub CleanList(%) {
     } # for
   } # while
 
-  my $msg    = 'Records deleted';
   $condition = "userid='$params{userid}' and type='$params{type}' and retention is not null";
 
   # First see if anything needs to be deleted
-  return (0, $msg) unless $db->count($table, $condition);
+  ($count, $msg) = $db->count($table, $condition);
+
+  return 0 unless $count;
 
   my ($err, $errmsg) = $db->find($table, $condition);
 
@@ -583,9 +585,9 @@ sub CleanList(%) {
   ResequenceList(
     userid => $params{userid},
     type   => $params{type},
-  ) if $count and !$params{dryrun};
+  ) if $count && !$params{dryrun};
 
-  return wantarray ? ($count, $msg) : $count; 
+  return $count;
 } # CleanList
 
 sub CountEmail(%) {