Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 77c6543

Browse files
authored
FIX: Embeddings backfill job compat when transitioning models (#1122)
When you already have embeddings for a model stored and change models, our backfill script was failing to backfill the newly configured model. Regression introduced most likely in 1686a8a
1 parent 708a3bd commit 77c6543

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

app/jobs/scheduled/embeddings_backfill.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def execute(args)
2626

2727
topics =
2828
Topic
29-
.joins("LEFT JOIN #{table_name} ON #{table_name}.topic_id = topics.id")
29+
.joins(
30+
"LEFT JOIN #{table_name} ON #{table_name}.topic_id = topics.id AND #{table_name}.model_id = #{vector_def.id}",
31+
)
3032
.where(archetype: Archetype.default)
3133
.where(deleted_at: nil)
3234
.order("topics.bumped_at DESC")
@@ -43,7 +45,7 @@ def execute(args)
4345
#{table_name}.strategy_version < #{vector_def.strategy_version}
4446
SQL
4547

46-
rebaked += populate_topic_embeddings(vector, relation)
48+
rebaked += populate_topic_embeddings(vector, relation, force: true)
4749

4850
return if rebaked >= limit
4951

@@ -67,7 +69,9 @@ def execute(args)
6769

6870
posts =
6971
Post
70-
.joins("LEFT JOIN #{table_name} ON #{table_name}.post_id = posts.id")
72+
.joins(
73+
"LEFT JOIN #{table_name} ON #{table_name}.post_id = posts.id AND #{table_name}.model_id = #{vector_def.id}",
74+
)
7175
.where(deleted_at: nil)
7276
.where(post_type: Post.types[:regular])
7377

0 commit comments

Comments
 (0)