This way I got rid of a couple of counterintuitive threading results. Namely real root of a thread would occasionally not be displayed as a root if a message containing the real root in the middle of its refs-list (dunno why) would get yielded (to threading algorithm) before the real root. Threading algorithm looks like it silently expects threaded messages to appear in cronological order.
Signed-off-by: Tero Tilus <t...@tilus.net> --- lib/sup/xapian_index.rb | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/lib/sup/xapian_index.rb b/lib/sup/xapian_index.rb index 0fdd55f..b31fd10 100644 --- a/lib/sup/xapian_index.rb +++ b/lib/sup/xapian_index.rb @@ -122,6 +122,7 @@ EOS return unless doc = find_doc(m.id) queue = doc.value(THREAD_VALUENO).split(',') msgids = [m.id] + msgdates = { m.id => m.date.to_i } seen_threads = Set.new seen_messages = Set.new [m.id] while not queue.empty? @@ -134,11 +135,15 @@ EOS msgid = doc.value MSGID_VALUENO next if seen_messages.member? msgid msgids << msgid + msgdates[msgid] = Xapian.sortable_unserialise(doc.value(DATE_VALUENO)).to_i seen_messages << msgid queue.concat doc.value(THREAD_VALUENO).split(',') end end - msgids.each { |id| yield id, lambda { build_message id } } + # We play nice and sort message ids by message date before + # yielding them. Threading for example gets messed up if messages + # are iterated in (more or less) random order. + msgids.sort { |a,b| msgdates[a] <=> msgdates[b] }.each { |id| yield id, lambda { build_message id } } true end -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ _______________________________________________ Sup-devel mailing list Sup-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-devel