X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Flib%2FMAPS.pm;h=705196e7aa7018222e377aeca2c933e973a2b8dd;hb=0ace35bef5b69543b6444447a7acf9bed8a9efd6;hp=0405483ae2b959ac9c2dc8f6884e56bb45954ebb;hpb=ae9e57b169de143d2b8a7c761c3bf7394385e0d0;p=clearscm.git diff --git a/maps/lib/MAPS.pm b/maps/lib/MAPS.pm index 0405483..705196e 100644 --- a/maps/lib/MAPS.pm +++ b/maps/lib/MAPS.pm @@ -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 @@ -306,7 +306,7 @@ sub AddList(%) { sub AddLog(%) { my (%params) = @_; - my $timestamp = UnixDatetime2SQLDatetime(scalar(localtime)); + $params{timestamp} = UnixDatetime2SQLDatetime(scalar(localtime)); return $db->add('log', %params); } # AddLog @@ -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,14 @@ 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; + + $count = 0; my ($err, $errmsg) = $db->find($table, $condition); @@ -570,9 +574,9 @@ sub CleanList(%) { . "$rec->{pattern}\@$rec->{domain} $dryrunstr"); $params{log}->dbug("last hit = $rec->{last_hit} < agedDate = $agedDate"); } # if - - $count++; } # unless + + $count++; } else { $params{log}->dbug("$rec->{userid}:$params{type}:$rec->{sequence}: nodelete $dryrunstr " . "last hit = $rec->{last_hit} >= agedDate = $agedDate") @@ -583,9 +587,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(%) {