Class: Textus::Infra::Store::Index::Lookup
- Inherits:
-
Object
- Object
- Textus::Infra::Store::Index::Lookup
- Defined in:
- lib/textus/infra/store/index/lookup.rb
Instance Method Summary collapse
- #find_by_hash(hash) ⇒ Object
- #find_by_url(url) ⇒ Object
-
#initialize(db) ⇒ Lookup
constructor
A new instance of Lookup.
Constructor Details
#initialize(db) ⇒ Lookup
Returns a new instance of Lookup.
6 7 8 |
# File 'lib/textus/infra/store/index/lookup.rb', line 6 def initialize(db) @db = db end |
Instance Method Details
#find_by_hash(hash) ⇒ Object
10 11 12 13 |
# File 'lib/textus/infra/store/index/lookup.rb', line 10 def find_by_hash(hash) row = @db[:entries].where(Sequel.lit("json_extract(content, '$.content_hash') = ?", hash)).first row&.dig(:key) end |
#find_by_url(url) ⇒ Object
15 16 17 18 |
# File 'lib/textus/infra/store/index/lookup.rb', line 15 def find_by_url(url) row = @db[:entries].where(Sequel.lit("json_extract(content, '$.source.url') = ?", url)).first row&.dig(:key) end |