From 1c40a698ca977a9788576dd8fc8344bba6ec0368 Mon Sep 17 00:00:00 2001
From: Roman Rizzi <roman@discourse.org>
Date: Fri, 13 Dec 2024 18:49:18 -0300
Subject: [PATCH] FIX: get strategy version through vector_rep (#1028)

---
 app/jobs/scheduled/embeddings_backfill.rb       | 2 +-
 spec/jobs/scheduled/embeddings_backfill_spec.rb | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/jobs/scheduled/embeddings_backfill.rb b/app/jobs/scheduled/embeddings_backfill.rb
index 0c4c0a9a..383c4c05 100644
--- a/app/jobs/scheduled/embeddings_backfill.rb
+++ b/app/jobs/scheduled/embeddings_backfill.rb
@@ -88,7 +88,7 @@ module Jobs
         .where(<<~SQL)
           #{table_name}.model_version < #{vector_rep.version}
           OR
-          #{table_name}.strategy_version < #{strategy.version}
+          #{table_name}.strategy_version < #{vector_rep.strategy_version}
         SQL
         .limit(limit - rebaked)
         .pluck(:id)
diff --git a/spec/jobs/scheduled/embeddings_backfill_spec.rb b/spec/jobs/scheduled/embeddings_backfill_spec.rb
index b54c2c80..c7fcc436 100644
--- a/spec/jobs/scheduled/embeddings_backfill_spec.rb
+++ b/spec/jobs/scheduled/embeddings_backfill_spec.rb
@@ -25,6 +25,7 @@ RSpec.describe Jobs::EmbeddingsBackfill do
     SiteSetting.ai_embeddings_enabled = true
     SiteSetting.ai_embeddings_discourse_service_api_endpoint = "http://test.com"
     SiteSetting.ai_embeddings_backfill_batch_size = 1
+    SiteSetting.ai_embeddings_per_post_enabled = true
     Jobs.run_immediately!
   end