Skip to content

Commit

Permalink
xapian: tidy up indexing code
Browse files Browse the repository at this point in the history
  • Loading branch information
johnl committed Apr 5, 2020
1 parent c69af6e commit 03f995e
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions app/models/news_article_version/xapian_indexing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,12 @@ def xapian_batch_index(records)
def xapian_update(options = {})
batch_size = options[:batch_size]
max_batches = options[:max_batches]
begin
last = xapian_db.documents.max(:id)
rescue IOError
last = nil
end
if last
logger.info("task=xapian_update last_news_article_versions_id=#{last.id}")
total = xapian_rebuild(conditions: ['news_article_versions.id > ?', last.id],
batch_size: batch_size,
max_batches: max_batches)
else
# No last id so rebuild the whole db
total = xapian_rebuild(batch_size: batch_size, max_batches: max_batches)
end
xapian_db.rw
last_id = xapian_db.documents.max(:id).try(:id) || 0
logger.info("task=xapian_update last_news_article_versions_id=#{last_id}")
total = xapian_rebuild(conditions: ['news_article_versions.id > ?', last_id],
batch_size: batch_size,
max_batches: max_batches)
xapian_db.flush
total
rescue Exception => e
Expand Down

0 comments on commit 03f995e

Please sign in to comment.