commit cf3d44d1c974075ff52957302291599f9c70a41e
parent 6761c010227619d24d49a7f166e29dae3e84ba74
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Wed, 12 Sep 2007 00:36:12 +0000
bugfix: label search for killed, deleted, spam
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@566 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
@@ -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
diff --git a/lib/sup/modes/label-search-results-mode.rb b/lib/sup/modes/label-search-results-mode.rb
@@ -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
diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb
@@ -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