Skip to content

Commit

Permalink
Updating how the articles "updated_at" filter works. (#2215)
Browse files Browse the repository at this point in the history
For the articles "updated_at" filter, consider only the articles that were actually changed after they were created. By default, it would include articles that were created but not changed.

Fixes: CV2-5851.
  • Loading branch information
caiosba authored Feb 12, 2025
1 parent 7d18de9 commit a7ccd92
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def filtered_explainers(filters = {})
query = query.where(user_id: filters[:user_ids].to_a.map(&:to_i)) unless filters[:user_ids].blank?

# Filter by date
query = query.where(updated_at: Range.new(*format_times_search_range_filter(JSON.parse(filters[:updated_at]), nil))) unless filters[:updated_at].blank?
query = query.where('explainers.created_at != explainers.updated_at').where(updated_at: Range.new(*format_times_search_range_filter(JSON.parse(filters[:updated_at]), nil))) unless filters[:updated_at].blank?
query = query.where(created_at: Range.new(*format_times_search_range_filter(JSON.parse(filters[:created_at]), nil))) unless filters[:created_at].blank?

# Filter by trashed
Expand Down Expand Up @@ -529,7 +529,7 @@ def filtered_fact_checks(filters = {})
query = query.where('fact_checks.user_id' => filters[:user_ids].to_a.map(&:to_i)) unless filters[:user_ids].blank?

# Filter by date
query = query.where('fact_checks.updated_at' => Range.new(*format_times_search_range_filter(JSON.parse(filters[:updated_at]), nil))) unless filters[:updated_at].blank?
query = query.where('fact_checks.created_at != fact_checks.updated_at').where('fact_checks.updated_at' => Range.new(*format_times_search_range_filter(JSON.parse(filters[:updated_at]), nil))) unless filters[:updated_at].blank?
query = query.where('fact_checks.created_at' => Range.new(*format_times_search_range_filter(JSON.parse(filters[:created_at]), nil))) unless filters[:created_at].blank?

# Filter by publisher
Expand Down

0 comments on commit a7ccd92

Please sign in to comment.