]> git.cworth.org Git - sup/commitdiff
fixed killed threads issue (i think)
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sun, 4 Feb 2007 23:42:50 +0000 (23:42 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sun, 4 Feb 2007 23:42:50 +0000 (23:42 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@301 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/index.rb
lib/sup/modes/thread-index-mode.rb
lib/sup/thread.rb

index 425c12fe8e50391530d27f89eae9b2c28018942c..cf56b45dcba14d399afbb66cfd5be2de10df6ab4 100644 (file)
@@ -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 }
index 14f219be9fdb3cc04eb759b6d7c377aeb898087d..34429642045f89f8acd266a454ce489fc07136b2 100644 (file)
@@ -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
index 439d7941175f35e6a7d43d715b50978f6c23eba4..1a92aea844646c6fdd00fb75986b99501adb2010 100644 (file)
@@ -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