From 2c78961bed075eb065939a25a1efb1c3d4c98fe4 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Thu, 21 Nov 2024 16:54:30 -0300 Subject: [PATCH] FIX: Properly capture period for /filter emotion ordering (#940) --- lib/sentiment/emotion_filter_order.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/sentiment/emotion_filter_order.rb b/lib/sentiment/emotion_filter_order.rb index 34cad293..22f0e67a 100644 --- a/lib/sentiment/emotion_filter_order.rb +++ b/lib/sentiment/emotion_filter_order.rb @@ -17,8 +17,7 @@ module DiscourseAi end &.expr &.split(">=") - &.last if scope.arel.constraints.present? && - scope.arel.constraints.any? { |c| c.is_a?(Arel::Nodes::Grouping) } + &.last if scope.to_sql.include?("topics.bumped_at >=") # Fallback in case we can't find the scope period scope_period ||= "CURRENT_DATE - INTERVAL '1 year'"