From: wmorgan Date: Wed, 12 Sep 2007 00:36:12 +0000 (+0000) Subject: bugfix: label search for killed, deleted, spam X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=cf3d44d1c974075ff52957302291599f9c70a41e;p=sup bugfix: label search for killed, deleted, spam git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@566 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- diff --git a/lib/sup/index.rb b/lib/sup/index.rb index f35b7f3..cb89abf 100644 --- 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 index 6c80dad..836ee66 100644 --- 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 index c9657c4..829c962 100644 --- 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