X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Flib%2FMAPS.pm;h=618fb67ed0ca9ecd5cbffc3fcdfb6e417c7442d0;hb=f6c2a9114dff9bf8882180bbf49ed6b3e3533a91;hp=e679d0064def2351bcd139c55aa112de7af75abb;hpb=8d1cd7efa187991ca2672c2dfc7fbff6a0682f09;p=clearscm.git diff --git a/maps/lib/MAPS.pm b/maps/lib/MAPS.pm index e679d00..618fb67 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 @@ -291,7 +291,7 @@ sub AddList(%) { $rec{hit_count} //= $db->count( 'email', - "userid = '$rec{userid}' and sender like '$rec{sender}%'" + "userid = '$rec{userid}' and sender like '%$rec{sender}%'" ); ($rec{pattern}, $rec{domain}) = split /\@/, delete $rec{sender}; @@ -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); @@ -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(%) { @@ -1009,7 +1013,7 @@ sub ResequenceList(%) { $db->lock('write', $table); # Get all records for $userid and $type - my $listrecs = $db->get($table, $condition); + my $listrecs = $db->get($table, $condition,'*', 'order by hit_count desc'); # Delete all of the list entries for this $userid and $type my ($count, $msg) = $db->delete($table, $condition);