From c6fc1a8047cb2707882cbc586065bf3bd7872aa2 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 15 Dec 2013 09:49:12 +0000 Subject: Fixed that filtering time entries on activity does not take care of activity overrides (#15623). git-svn-id: http://svn.redmine.org/redmine/trunk@12414 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/time_entry_query.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/time_entry_query.rb b/app/models/time_entry_query.rb index 3325b55a8..02bc10090 100644 --- a/app/models/time_entry_query.rb +++ b/app/models/time_entry_query.rb @@ -106,7 +106,20 @@ class TimeEntryQuery < Query TimeEntry.visible. where(statement). order(order_option). - joins(joins_for_order_statement(order_option.join(','))) + joins(joins_for_order_statement(order_option.join(','))). + includes(:activity) + end + + def sql_for_activity_id_field(field, operator, value) + condition_on_id = sql_for_field(field, operator, value, Enumeration.table_name, 'id') + condition_on_parent_id = sql_for_field(field, operator, value, Enumeration.table_name, 'parent_id') + ids = value.map(&:to_i).join(',') + table_name = Enumeration.table_name + if operator == '=' + "(#{table_name}.id IN (#{ids}) OR #{table_name}.parent_id IN (#{ids}))" + else + "(#{table_name}.id NOT IN (#{ids}) AND (#{table_name}.parent_id IS NULL OR #{table_name}.parent_id NOT IN (#{ids})))" + end end # Accepts :from/:to params as shortcut filters -- cgit v1.2.3