Module: Jekyll::EmbeddingsGenerator::Store
- Extended by:
- Jekyll::EmbeddingsGenerator
- Defined in:
- lib/jekyll/embeddings-generator/embeddings/store.rb
Constant Summary
Constants included from Jekyll::EmbeddingsGenerator
Class Method Summary collapse
- .find_related(post) ⇒ Object
-
.store_embedding(data) ⇒ Object
rubocop:disable Metrics/AbcSize.
Methods included from Jekyll::EmbeddingsGenerator
Class Method Details
.find_related(post) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/jekyll/embeddings-generator/embeddings/store.rb', line 48 def (post) config = Jekyll::EmbeddingsGenerator.config post_uid = post.data[config["uid"]] = (post_uid) (, post_uid) end |
.store_embedding(data) ⇒ Object
rubocop:disable Metrics/AbcSize
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/jekyll/embeddings-generator/embeddings/store.rb', line 12 def (data) # rubocop:disable Metrics/AbcSize config = Jekyll::EmbeddingsGenerator.config supabase_url = config["supabase_url"] supabase_key = config["supabase_key"] table = config["db_table"] # First check if record exists and its edit date existing = HTTParty.get( "#{supabase_url}/rest/v1/#{table}", :headers => { "apikey" => supabase_key, "Authorization" => "Bearer #{supabase_key}", "Content-Type" => "application/json", "Accept-Encoding" => "identity", # this to avoid supabase returning gzipped content }, :query => { "uid" => "eq.#{data.uid}", "select" => "uid, most_recent_edit", } ) Jekyll.logger.debug "response headers: #{existing.headers}" Jekyll.logger.debug "response body: #{existing.body}" raise "Supabase API error: #{existing.code} - #{existing.body}" unless existing.success? existing_record = existing.parsed_response&.first mre = data.most_recent_edit should_update = existing_record.nil? || Time.parse(existing_record["most_recent_edit"]) < mre Jekyll.logger.debug "Embeddings Generator:", "Should update? #{should_update ? "Yes" : "No"}" return false unless should_update (data) end |