Class: ContentEmbedding::PostEmbedding
- Inherits:
-
ContentEmbedding
- Object
- ContentEmbedding
- ContentEmbedding::PostEmbedding
- Includes:
- TextSearchable
- Defined in:
- app/models/content_embedding/post_embedding.rb
Overview
== Schema Information
Table name: content_embeddings_posts
Database name: primary
id :bigint not null, primary key
content_hash :string(32)
content_type :string default("primary"), not null
embeddable_type :string not null
embedding_dimensions :integer
embedding_model :string
locale :string default("en")
model :string
token_count :integer
unified_embedding :vector
created_at :timestamp not null
updated_at :timestamp not null
embeddable_id :bigint not null
Indexes
idx_content_embeddings_posts_embedding_model (embedding_model)
idx_content_embeddings_posts_unique (embeddable_id,content_type,locale) UNIQUE
Foreign Keys
fk_content_embeddings_posts_embeddable (embeddable_id => articles.id) ON DELETE => cascade
ContentEmbedding STI subclass for post embeddings.
Constant Summary
Constants included from TextSearchable
TextSearchable::SIMILARITY_THRESHOLD
Belongs to collapse
- #embeddable ⇒ Post (also: #post)
Class Method Summary collapse
-
.apply_published_filter(scope) ⇒ ActiveRecord::Relation
Filter to published posts only.
-
.primary_content ⇒ ActiveRecord::Relation<ContentEmbedding::PostEmbedding>
A relation of ContentEmbedding::PostEmbeddings that are primary content.
Methods included from TextSearchable
apply_locale_filter, generate_text_query_embedding, locale_filtered?, semantic_search
Class Method Details
.apply_published_filter(scope) ⇒ ActiveRecord::Relation
Filter to published posts only
52 53 54 55 |
# File 'app/models/content_embedding/post_embedding.rb', line 52 def apply_published_filter(scope) scope.joins('INNER JOIN articles ON articles.id = content_embeddings_posts.embeddable_id') .where(articles: { state: 'published' }) end |
.primary_content ⇒ ActiveRecord::Relation<ContentEmbedding::PostEmbedding>
A relation of ContentEmbedding::PostEmbeddings that are primary content. Active Record Scope
45 |
# File 'app/models/content_embedding/post_embedding.rb', line 45 scope :primary_content, -> { where(content_type: 'primary') } |
Instance Method Details
#embeddable ⇒ Post Also known as: post
40 |
# File 'app/models/content_embedding/post_embedding.rb', line 40 belongs_to :embeddable, class_name: 'Post' |