Class: Upkeep::Subscriptions::PersistentReverseIndex
- Inherits:
-
Object
- Object
- Upkeep::Subscriptions::PersistentReverseIndex
- Defined in:
- lib/upkeep/subscriptions/persistent_reverse_index.rb
Constant Summary collapse
- LOOKUP_COLUMNS =
[ :subscription_id, :lookup_key_digest, :dependency_source, :lookup_table, :lookup_record_id_snapshot, :lookup_attribute, :dependency_table, :dependency_predicate_digest, :dependency_metadata_snapshot, :owner_ids_snapshot ].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #entries_for(changes) ⇒ Object
-
#initialize(reverse_index:, index_record:) ⇒ PersistentReverseIndex
constructor
A new instance of PersistentReverseIndex.
- #summary ⇒ Object
Constructor Details
#initialize(reverse_index:, index_record:) ⇒ PersistentReverseIndex
Returns a new instance of PersistentReverseIndex.
25 26 27 28 |
# File 'lib/upkeep/subscriptions/persistent_reverse_index.rb', line 25 def initialize(reverse_index:, index_record:) @reverse_index = reverse_index @index_record = index_record end |
Class Method Details
.canonical_lookup_value(value) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/upkeep/subscriptions/persistent_reverse_index.rb', line 45 def self.canonical_lookup_value(value) case value when Array value.map { |item| canonical_lookup_value(item) } when Hash value.keys.sort_by(&:to_s).map do |key| [canonical_lookup_value(key), canonical_lookup_value(value.fetch(key))] end when Symbol ["symbol", value.to_s] when String ["string", value.encode(Encoding::UTF_8)] else value end end |
.digest(value) ⇒ Object
41 42 43 |
# File 'lib/upkeep/subscriptions/persistent_reverse_index.rb', line 41 def self.digest(value) Digest::SHA256.hexdigest(JSON.generate(canonical_lookup_value(value))) end |
Instance Method Details
#entries_for(changes) ⇒ Object
30 31 32 |
# File 'lib/upkeep/subscriptions/persistent_reverse_index.rb', line 30 def entries_for(changes) persistent_entries_for(changes) end |
#summary ⇒ Object
34 35 36 37 38 39 |
# File 'lib/upkeep/subscriptions/persistent_reverse_index.rb', line 34 def summary { lookup_keys: index_record.distinct.count(:lookup_key_digest), entries: index_record.count } end |