Class: Chewy::Stash::Journal
Constant Summary
Constants inherited from Index
Index::IMPORT_OPTIONS_KEYS, Index::STRATEGY_OPTIONS
Constants included from Index::Import
Index::Import::IMPORT_WORKER, Index::Import::LEFTOVERS_WORKER
Class Method Summary collapse
-
.clean(until_time = nil, only: [], delete_by_query_options: {}) ⇒ Object
Cleans up all the journal entries until the specified time.
-
.entries(since_time, only: []) ⇒ Object
Loads all entries since the specified time.
-
.for(*something) ⇒ Object
Selects all the journal entries for the specified indices.
Instance Method Summary collapse
Methods inherited from Index
base_name, default_import_options, derivable_name, index_name, index_scope, mappings_hash, prefix, scopes, settings, settings_hash, specification, specification_hash, strategy_config
Methods included from Index::Wrapper
#==, #initialize, #method_missing, #respond_to_missing?
Methods included from Index::Observe::Helpers
#extract_callback_options!, #update_proc
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chewy::Index::Wrapper
Class Method Details
.clean(until_time = nil, only: [], delete_by_query_options: {}) ⇒ Object
Cleans up all the journal entries until the specified time. If nothing is specified - cleans up everything.
33 34 35 36 37 |
# File 'lib/chewy/stash.rb', line 33 def self.clean(until_time = nil, only: [], delete_by_query_options: {}) scope = self.for(only) scope = scope.filter(range: {created_at: {lte: until_time}}) if until_time scope.delete_all(**) end |
.entries(since_time, only: []) ⇒ Object
Loads all entries since the specified time.
24 25 26 |
# File 'lib/chewy/stash.rb', line 24 def self.entries(since_time, only: []) self.for(only).filter(range: {created_at: {gt: since_time}}).filter.minimum_should_match(1) end |
.for(*something) ⇒ Object
Selects all the journal entries for the specified indices.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/chewy/stash.rb', line 42 def self.for(*something) something = something.flatten.compact indexes = something.flat_map { |s| Chewy.derive_name(s) } return none if something.present? && indexes.blank? scope = all indexes.each do |index| scope = scope.or(filter(term: {index_name: index.derivable_name})) end scope end |
Instance Method Details
#references ⇒ Object
61 62 63 64 65 |
# File 'lib/chewy/stash.rb', line 61 def references @references ||= Array.wrap(@attributes['references']).map do |item| JSON.load(Base64.decode64(item)) # rubocop:disable Security/JSONLoad end end |