X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fxapian_index.rb;fp=lib%2Fsup%2Fxapian_index.rb;h=c2607283fd20e61a37be94b39fc84d5ec88cf2ee;hb=afeaf4393206cce3f4b91d40ec50fae2ba0e6f2f;hp=7e65a704d7fbe6764114b32980115a87207fb255;hpb=b633754b55d6d449dc87634c8e572dbfdb20e0b6;p=sup diff --git a/lib/sup/xapian_index.rb b/lib/sup/xapian_index.rb index 7e65a70..c260728 100644 --- a/lib/sup/xapian_index.rb +++ b/lib/sup/xapian_index.rb @@ -84,6 +84,10 @@ class XapianIndex < BaseIndex m end + def add_message m; sync_message m end + def update_message m; sync_message m end + def update_message_state m; sync_message m end + def sync_message m, opts={} entry = synchronize { get_entry m.id } snippet = m.snippet @@ -97,7 +101,7 @@ class XapianIndex < BaseIndex :source_info => m.source_info, :date => (entry[:date] || m.date), :snippet => snippet, - :labels => labels.uniq, + :labels => labels, :from => (entry[:from] || [m.from.email, m.from.name]), :to => (entry[:to] || m.to.map { |p| [p.email, p.name] }), :cc => (entry[:cc] || m.cc.map { |p| [p.email, p.name] }), @@ -107,13 +111,14 @@ class XapianIndex < BaseIndex :replytos => (entry[:replytos] || m.replytos), } - m.labels.each { |l| LabelManager << l } + labels.each { |l| LabelManager << l } synchronize do index_message m, d, opts end true end + private :sync_message def num_results_for query={} xapian_query = build_xapian_query query @@ -229,10 +234,10 @@ class XapianIndex < BaseIndex field, name = $1, ($3 || $4) case field when "filename" - Redwood::log "filename - translated #{field}:#{name} to attachment:\"#{name.downcase}\"" + debug "filename: translated #{field}:#{name} to attachment:\"#{name.downcase}\"" "attachment:\"#{name.downcase}\"" when "filetype" - Redwood::log "filetype - translated #{field}:#{name} to attachment_extension:#{name.downcase}" + debug "filetype: translated #{field}:#{name} to attachment_extension:#{name.downcase}" "attachment_extension:#{name.downcase}" end end @@ -246,13 +251,13 @@ class XapianIndex < BaseIndex if realdate case field when "after" - Redwood::log "chronic: translated #{field}:#{datestr} to #{realdate.end}" + debug "chronic: translated #{field}:#{datestr} to #{realdate.end}" "date:#{realdate.end.to_i}..#{lastdate}" when "before" - Redwood::log "chronic: translated #{field}:#{datestr} to #{realdate.begin}" + debug "chronic: translated #{field}:#{datestr} to #{realdate.begin}" "date:#{firstdate}..#{realdate.end.to_i}" else - Redwood::log "chronic: translated #{field}:#{datestr} to #{realdate}" + debug "chronic: translated #{field}:#{datestr} to #{realdate}" "date:#{realdate.begin.to_i}..#{realdate.end.to_i}" end else @@ -478,10 +483,10 @@ class XapianIndex < BaseIndex m.attachments.each { |a| text << [a, PREFIX['attachment']] } truncated_date = if m.date < MIN_DATE - Redwood::log "warning: adjusting too-low date #{m.date} for indexing" + debug "warning: adjusting too-low date #{m.date} for indexing" MIN_DATE elsif m.date > MAX_DATE - Redwood::log "warning: adjusting too-high date #{m.date} for indexing" + debug "warning: adjusting too-high date #{m.date} for indexing" MAX_DATE else m.date