commit 22b9237fa5b7124ef7774d6a40a8f93bc1ff8d56
parent e8a8134b67c4b7f2c9acfa9c900fa513b3cbebd0
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Sun, 4 Feb 2007 23:42:50 +0000
fixed killed threads issue (i think)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@301 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
3 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
@@ -87,6 +87,7 @@ class Index
@index.delete docid
add_message m
+ docid, entry = load_entry_for_id m.id
end
## for each new message form the source, yields a bunch of stuff,
@@ -124,7 +125,7 @@ class Index
update_message m, docid, entry
else
add_message m
- UpdateManager.relay :add, m if UpdateManager.instantiated?
+ UpdateManager.relay :add, m
end
rescue MessageFormatError, SourceError => e
Redwood::log "ignoring erroneous message at #{source}##{offset}: #{e.message}"
@@ -143,8 +144,7 @@ class Index
def size; @index.size; end
## you should probably not call this on a block that doesn't break
- ## rather quickly because the results will probably be, as we say
- ## in scotland, frikkin' huuuge.
+ ## rather quickly because the results can be very large.
EACH_BY_DATE_NUM = 100
def each_id_by_date opts={}
return if @index.size == 0 # otherwise ferret barfs ###TODO: remove this once my ferret patch is accepted
@@ -166,20 +166,20 @@ class Index
end
## yield all messages in the thread containing 'm' by repeatedly
- ## querying the index. yields pairs of message ids and
+ ## querying the index. uields pairs of message ids and
## 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.
+
SAME_SUBJECT_DATE_LIMIT = 7
def each_message_in_thread_for m, opts={}
messages = {}
searched = {}
num_queries = 0
- ## temporarily disabling subject searching because it's a
- ## significant slowdown.
- ##
- ## TODO: make this configurable, i guess
- if true
+ ## todo: make subject querying configurable
+ if true # do subject queries
date_min = m.date - (SAME_SUBJECT_DATE_LIMIT * 12 * 3600)
date_max = m.date + (SAME_SUBJECT_DATE_LIMIT * 12 * 3600)
@@ -189,9 +189,10 @@ class Index
sq.add_term t
end
q.add_query sq, :must
- q.add_query Ferret::Search::TermQuery.new(:label, "spam"), :must_not
q.add_query Ferret::Search::RangeQuery.new(:date, :>= => date_min.to_indexable_s, :<= => date_max.to_indexable_s), :must
+ q = build_query :qobj => q
+
pending = @index.search(q).hits.map { |hit| @index[hit.doc][:message_id] }
Redwood::log "found #{pending.size} results for subject query #{q}"
else
@@ -206,9 +207,12 @@ class Index
q.add_query Ferret::Search::TermQuery.new(:message_id, id), :should
q.add_query Ferret::Search::TermQuery.new(:refs, id), :should
+ q = build_query :qobj => q, :load_killed => true
+
num_queries += 1
@index.search_each(q, :limit => :all) do |docid, score|
break if opts[:limit] && messages.size >= opts[:limit]
+ break if @index[docid][:label].split(/\s+/).include? "killed" unless opts[:load_killed]
mid = @index[docid][:message_id]
unless messages.member? mid
messages[mid] ||= lambda { build_message docid }
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -112,7 +112,7 @@ class ThreadIndexMode < LineCursorMode
def update
## let's see you do THIS in python
- @threads = @ts.threads.select { |t| !@hidden_threads[t] }.sort_by { |t| t.date }.reverse
+ @threads = @ts.threads.select { |t| !@hidden_threads[t] && !t.has_label?(:killed) }.sort_by { |t| t.date }.reverse
@size_width = (@threads.map { |t| t.size }.max || 0).num_digits
regen_text
end
diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb
@@ -292,14 +292,14 @@ class ThreadSet
m = builder.call
add_message m
- load_thread_for_message m
+ load_thread_for_message m, :load_killed => opts[:load_killed]
yield @subj_thread.size if block_given?
end
end
## loads in all messages needed to thread m
- def load_thread_for_message m
- @index.each_message_in_thread_for m, :limit => 100 do |mid, builder|
+ def load_thread_for_message m, opts
+ @index.each_message_in_thread_for m, opts.merge({:limit => 100}) do |mid, builder|
next if contains_id? mid
add_message builder.call
end