Class: ContentEmbedding::PostEmbedding

Inherits:
ContentEmbedding
  • Object
show all
Includes:
TextSearchable
Defined in:
app/models/content_embedding/post_embedding.rb

Constant Summary

Constants included from TextSearchable

TextSearchable::EMBEDDING_MODEL, TextSearchable::SIMILARITY_THRESHOLD

Belongs to collapse

Class Method Summary collapse

Methods included from TextSearchable

apply_locale_filter, generate_text_query_embedding, locale_filtered?, semantic_search

Class Method Details

.apply_published_filter(scope) ⇒ Object

Filter to published posts only



48
49
50
51
# File 'app/models/content_embedding/post_embedding.rb', line 48

def apply_published_filter(scope)
  scope.joins('INNER JOIN articles ON articles.id = content_embeddings_posts.embeddable_id')
       .where(articles: { state: 'published' })
end

.primary_contentActiveRecord::Relation<ContentEmbedding::PostEmbedding>

A relation of ContentEmbedding::PostEmbeddings that are primary content. Active Record Scope

Returns:

See Also:



43
# File 'app/models/content_embedding/post_embedding.rb', line 43

scope :primary_content, -> { where(content_type: 'primary') }

.with_embeddingActiveRecord::Relation<ContentEmbedding::PostEmbedding>

A relation of ContentEmbedding::PostEmbeddings that are with embedding. Active Record Scope

Returns:

See Also:



44
# File 'app/models/content_embedding/post_embedding.rb', line 44

scope :with_embedding, -> { where.not(embedding: nil) }

Instance Method Details

#embeddablePost Also known as: post

Returns:

See Also:



38
# File 'app/models/content_embedding/post_embedding.rb', line 38

belongs_to :embeddable, class_name: 'Post'