From 59fbbb156b33159bd62b34420132e01a0bef7789 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Fri, 9 Feb 2024 16:08:54 -0300 Subject: [PATCH] DEV: Make indexing less frequent when related topics is disabled (#468) --- lib/embeddings/vector_representations/base.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/embeddings/vector_representations/base.rb b/lib/embeddings/vector_representations/base.rb index fc944cf0..61c24789 100644 --- a/lib/embeddings/vector_representations/base.rb +++ b/lib/embeddings/vector_representations/base.rb @@ -85,7 +85,15 @@ module DiscourseAi ).first existing_lists = existing_index.match(/lists='(\d+)'/)&.captures&.first&.to_i - if existing_index_age > 0 && existing_index_age < 1.hour.ago.to_i + if existing_index_age > 0 && + existing_index_age < + ( + if SiteSetting.ai_embeddings_semantic_related_topics_enabled + 1.hour.ago.to_i + else + 1.day.ago.to_i + end + ) if new_rows > 10_000 Rails.logger.info( "Index #{index_name} is #{existing_index_age} seconds old, and there are #{new_rows} new rows, updating...",