Class: Textus::Infra::Store::Index::Lookup

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/infra/store/index/lookup.rb

Instance Method Summary collapse

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