diff options
author | Go MAEDA <maeda@farend.jp> | 2019-04-30 10:52:18 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-04-30 10:52:18 +0000 |
commit | 81e06a2f25f81abea90109719647c860221231d9 (patch) | |
tree | f8cd9efd0ae2241b4564dd638b399b13d6b6123f /app/models/issue_query.rb | |
parent | 451b6a98f752b3b5087ee2b8e5ca878bfae1eca7 (diff) | |
download | redmine-81e06a2f25f81abea90109719647c860221231d9.tar.gz redmine-81e06a2f25f81abea90109719647c860221231d9.zip |
Issue filtering by spent time (#26826).
Patch by Tobias Umbach and Takenori TAKAKI.
git-svn-id: http://svn.redmine.org/redmine/trunk@18112 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue_query.rb')
-rw-r--r-- | app/models/issue_query.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 365b13d38..b9457c93c 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -137,6 +137,11 @@ class IssueQuery < Query add_available_filter "start_date", :type => :date add_available_filter "due_date", :type => :date add_available_filter "estimated_hours", :type => :float + + if User.current.allowed_to?(:view_time_entries, project, :global => true) + add_available_filter "spent_time", :type => :float, :label => :label_spent_time + end + add_available_filter "done_ratio", :type => :integer if User.current.allowed_to?(:set_issues_private, nil, :global => true) || @@ -389,6 +394,24 @@ class IssueQuery < Query "#{neg} EXISTS (#{subquery})" end + def sql_for_spent_time_field(field, operator, value) + first, second = value.first.to_f, value.second.to_f + + sql_op = + case operator + when "=", ">=", "<=" ; "#{operator} #{first}" + when "><" ; "BETWEEN #{first} AND #{second}" + when "*" ; "> 0" + when "!*" ; "= 0" + else ; return nil + end + + "COALESCE((" + + "SELECT ROUND(CAST(SUM(hours) AS DECIMAL(30,3)), 2) " + + "FROM #{TimeEntry.table_name} " + + "WHERE issue_id = #{Issue.table_name}.id), 0) #{sql_op}" + end + def sql_for_watcher_id_field(field, operator, value) db_table = Watcher.table_name |