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'"