FIX: Change how we filter date for emotion on /filter (#1006)
This commit is contained in:
parent
4ba74511c2
commit
5ba274f7a5
|
@ -12,15 +12,18 @@ module DiscourseAi
|
|||
&.constraints
|
||||
&.flat_map(&:children)
|
||||
&.find do |node|
|
||||
node.is_a?(Arel::Nodes::Grouping) &&
|
||||
node.expr.to_s.match?(/topics\.bumped_at\s*>=/)
|
||||
node.is_a?(Arel::Nodes::BoundSqlLiteral) &&
|
||||
node.to_sql.match?(/topics\.bumped_at\s*>=/)
|
||||
end
|
||||
&.expr
|
||||
&.split(">=")
|
||||
&.last if scope.to_sql.include?("topics.bumped_at >=")
|
||||
&.positional_binds
|
||||
&.first if scope.to_sql.include?("topics.bumped_at >=")
|
||||
|
||||
if scope_period.is_a?(ActiveSupport::TimeWithZone)
|
||||
scope_period = "'#{scope_period.to_date}'"
|
||||
else
|
||||
# Fallback in case we can't find the scope period
|
||||
scope_period ||= "CURRENT_DATE - INTERVAL '1 year'"
|
||||
scope_period = "CURRENT_DATE - INTERVAL '1 year'"
|
||||
end
|
||||
|
||||
emotion_clause = <<~SQL
|
||||
COUNT(*) FILTER (WHERE (classification_results.classification::jsonb->'#{emotion}')::float > 0.1)
|
||||
|
|
Loading…
Reference in New Issue