Skip to content

Commit

Permalink
Don't index until we have Sidekiq online
Browse files Browse the repository at this point in the history
  • Loading branch information
dbackeus committed Sep 12, 2023
1 parent 01a00c9 commit 5ea813c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/models/concerns/elasticsearchable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ module Elasticsearchable
end
end

# Override this method to control when the model should be indexed
# Override this method to control when the model should be indexed.
# By default we skip indexing unless Sidekiq is connected to Redis
# to avoid raising errors after commit.
def should_index?
true
Sidekiq.redis(&:info) rescue false
end

def elasticsearch_id
Expand Down
2 changes: 1 addition & 1 deletion app/models/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def elasticsearch_content
private

def should_index?
state == "success"
super && state == "success"
end

def enqueue_crawl_job
Expand Down

0 comments on commit 5ea813c

Please sign in to comment.