diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/chewy/accounts_index.rb | 2 | ||||
-rw-r--r-- | app/chewy/statuses_index.rb | 2 | ||||
-rw-r--r-- | app/chewy/tags_index.rb | 2 | ||||
-rw-r--r-- | app/workers/scheduler/indexing_scheduler.rb | 26 |
4 files changed, 29 insertions, 3 deletions
diff --git a/app/chewy/accounts_index.rb b/app/chewy/accounts_index.rb index 6f9ea76e9..763958a3f 100644 --- a/app/chewy/accounts_index.rb +++ b/app/chewy/accounts_index.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class AccountsIndex < Chewy::Index - settings index: { refresh_interval: '5m' }, analysis: { + settings index: { refresh_interval: '30s' }, analysis: { analyzer: { content: { tokenizer: 'whitespace', diff --git a/app/chewy/statuses_index.rb b/app/chewy/statuses_index.rb index 1304aeedb..c20009879 100644 --- a/app/chewy/statuses_index.rb +++ b/app/chewy/statuses_index.rb @@ -3,7 +3,7 @@ class StatusesIndex < Chewy::Index include FormattingHelper - settings index: { refresh_interval: '15m' }, analysis: { + settings index: { refresh_interval: '30s' }, analysis: { filter: { english_stop: { type: 'stop', diff --git a/app/chewy/tags_index.rb b/app/chewy/tags_index.rb index f9db2b03a..a5b139bca 100644 --- a/app/chewy/tags_index.rb +++ b/app/chewy/tags_index.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class TagsIndex < Chewy::Index - settings index: { refresh_interval: '15m' }, analysis: { + settings index: { refresh_interval: '30s' }, analysis: { analyzer: { content: { tokenizer: 'keyword', diff --git a/app/workers/scheduler/indexing_scheduler.rb b/app/workers/scheduler/indexing_scheduler.rb new file mode 100644 index 000000000..3a6f47a29 --- /dev/null +++ b/app/workers/scheduler/indexing_scheduler.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class Scheduler::IndexingScheduler + include Sidekiq::Worker + include Redisable + + sidekiq_options retry: 0 + + def perform + indexes.each do |type| + with_redis do |redis| + ids = redis.smembers("chewy:queue:#{type.name}") + + type.import!(ids) + + redis.pipelined do |pipeline| + ids.each { |id| pipeline.srem("chewy:queue:#{type.name}", id) } + end + end + end + end + + def indexes + [AccountsIndex, TagsIndex, StatusesIndex] + end +end |