Fixed bug with counting messages
[clearscm.git] / maps / lib / MAPS.pm
index d63f9b9..618fb67 100644 (file)
@@ -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};
@@ -544,6 +544,8 @@ sub CleanList(%) {
 
   return 0 unless $count;
 
+  $count = 0;
+
   my ($err, $errmsg) = $db->find($table, $condition);
 
   croak "Unable to find $params{type} entries for $condition - $errmsg" if $err;
@@ -1011,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);