]> git.cworth.org Git - sup/commitdiff
bugfix: label search for killed, deleted, spam
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 12 Sep 2007 00:36:12 +0000 (00:36 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Wed, 12 Sep 2007 00:36:12 +0000 (00:36 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@566 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/index.rb
lib/sup/modes/label-search-results-mode.rb
lib/sup/thread.rb

index f35b7f3beac676a7a75e402602f399501308d784..cb89abf8b89215188fa021efc7d58370b0297581 100644 (file)
@@ -262,6 +262,8 @@ EOS
       q.add_query Ferret::Search::TermQuery.new(:message_id, id), :should
       q.add_query Ferret::Search::TermQuery.new(:refs, id), :should
 
+      ## load_killed is true so that we can abort if any message in
+      ## the thread has the killed label.
       q = build_query :qobj => q, :load_killed => true
 
       num_queries += 1
@@ -283,9 +285,11 @@ EOS
     end
     if killed
       Redwood::log "thread for #{m.id} is killed, ignoring"
+      false
     else
       Redwood::log "ran #{num_queries} queries to build thread of #{messages.size + 1} messages for #{m.id}: #{m.subj}" if num_queries > 0
       messages.each { |mid, builder| yield mid, builder }
+      true
     end
   end
 
index 6c80dadbcd569de93c21b6c5f0553ed6524b10fb..836ee6602389a6e8fde4450e382f4aa888df3d5e 100644 (file)
@@ -3,7 +3,11 @@ module Redwood
 class LabelSearchResultsMode < ThreadIndexMode
   def initialize labels
     @labels = labels
-    super [], { :labels => @labels }
+    opts = { :labels => @labels }
+    opts[:load_killed] = true if labels.include? :killed
+    opts[:load_deleted] = true if labels.include? :deleted
+    opts[:load_spam] = true if labels.include? :spam
+    super [], opts
   end
 
   def is_relevant? m; @labels.all? { |l| m.has_label? l }; end
index c9657c45ecb3d312d6daaeea40d9a8334cf57ba0..829c962c3f2a44ab2857c6c8c7ea7bbeb8c6a497 100644 (file)
@@ -298,22 +298,26 @@ class ThreadSet
 
   ## load in (at most) num number of threads from the index
   def load_n_threads num, opts={}
+    Redwood::log "xx each_id_by_date #{opts.inspect}"
     @index.each_id_by_date opts do |mid, builder|
       break if size >= num
       next if contains_id? mid
 
       m = builder.call
-      load_thread_for_message m, :load_killed => opts[:load_killed]
+      load_thread_for_message m, :load_killed => opts[:load_killed], :load_deleted => opts[:load_deleted], :load_spam => opts[:load_spam]
       yield size if block_given?
     end
   end
 
   ## loads in all messages needed to thread m
+  ## may do nothing if m's thread is killed
   def load_thread_for_message m, opts={}
-    @index.each_message_in_thread_for m, opts.merge({:limit => 100}) do |mid, builder|
+    good = @index.each_message_in_thread_for m, opts do |mid, builder|
+      Redwood::log "  > got #{mid}"
       next if contains_id? mid
       add_message builder.call
     end
+    add_message m if good
   end
 
   ## merges in a pre-loaded thread