]> git.cworth.org Git - sup/commitdiff
rename :load_killed to :skip_killed and switched logic so that killed threads are...
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 29 Oct 2007 15:41:39 +0000 (15:41 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 29 Oct 2007 15:41:39 +0000 (15:41 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@646 5c8cc53c-5e98-4d25-b20a-d8db53a31250

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

index 82fa1734017e5115203aa234c315de4d0deea5d7..7dff1cd3e2e6ea0ce8f0aa758a5c201fadd91de2 100644 (file)
@@ -225,7 +225,9 @@ EOS
   ## message-building lambdas, so that building an unwanted message
   ## can be skipped in the block if desired.
   ##
-  ## stops loading any thread if a message with a :killed flag is found.
+  ## only two options, :limit and :skip_killed. if :skip_killed is
+  ## true, stops loading any thread if a message with a :killed flag
+  ## is found.
   SAME_SUBJECT_DATE_LIMIT = 7
   def each_message_in_thread_for m, opts={}
     #Redwood::log "Building thread for #{m.id}: #{m.subj}"
@@ -261,15 +263,13 @@ 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
+      q = build_query :qobj => q
 
       num_queries += 1
       killed = false
       @index.search_each(q, :limit => :all) do |docid, score|
         break if opts[:limit] && messages.size >= opts[:limit]
-        if @index[docid][:label].split(/\s+/).include?("killed") && !opts[:load_killed]
+        if @index[docid][:label].split(/\s+/).include?("killed") && opts[:skip_killed]
           killed = true
           break
         end
@@ -400,7 +400,7 @@ protected
         
     query.add_query Ferret::Search::TermQuery.new("label", "spam"), :must_not unless opts[:load_spam] || labels.include?(:spam)
     query.add_query Ferret::Search::TermQuery.new("label", "deleted"), :must_not unless opts[:load_deleted] || labels.include?(:deleted)
-    query.add_query Ferret::Search::TermQuery.new("label", "killed"), :must_not unless opts[:load_killed] || labels.include?(:killed)
+    query.add_query Ferret::Search::TermQuery.new("label", "killed"), :must_not if opts[:skip_killed]
     query
   end
 
index 23da9795b438db83912ee943ff750d7e7f992997..aa40318529144968fe2af078d59b51d42fe566ba 100644 (file)
@@ -9,7 +9,7 @@ class InboxMode < ThreadIndexMode
   end
 
   def initialize
-    super [:inbox, :sent], { :label => :inbox }
+    super [:inbox, :sent], { :label => :inbox, :skip_killed => true }
     raise "can't have more than one!" if defined? @@instance
     @@instance = self
   end
index 836ee6602389a6e8fde4450e382f4aa888df3d5e..9fc051f137c83d27b686be43df3707ca5e95837b 100644 (file)
@@ -4,7 +4,6 @@ class LabelSearchResultsMode < ThreadIndexMode
   def initialize labels
     @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
index 1b0d4569b9e51ee507d8ee35f26780a162c80a29..73e98090f1302fc87464b8728550cc94b72c2528 100644 (file)
@@ -3,7 +3,7 @@ module Redwood
 class SearchResultsMode < ThreadIndexMode
   def initialize qobj
     @qobj = qobj
-    super [], { :qobj => @qobj, :load_killed => true, :load_spam => false }
+    super [], { :qobj => @qobj }
   end
 
   ## a proper is_relevant? method requires some way of asking ferret
index b154ac02925fdf89e67b563b4e2636b1ad1d134d..722ba344bb5343fd345214329fc92f046e2ab693 100644 (file)
@@ -306,7 +306,7 @@ class ThreadSet
       next if contains_id? mid
 
       m = builder.call
-      load_thread_for_message m, :load_killed => opts[:load_killed], :load_deleted => opts[:load_deleted], :load_spam => opts[:load_spam]
+      load_thread_for_message m, :skip_killed => opts[:skip_killed], :load_deleted => opts[:load_deleted], :load_spam => opts[:load_spam]
       yield size if block_given?
     end
   end