diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2018-12-12 19:52:28 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2018-12-12 19:52:28 +0000 |
commit | e647e99b741ce0360ee479925009076f48d0d8a5 (patch) | |
tree | e4f9bf27a97cbae1842e7e3448c3055cfe5dad48 /app | |
parent | 72980f41751a4d09c965733638572f799146e3e3 (diff) | |
download | redmine-e647e99b741ce0360ee479925009076f48d0d8a5.tar.gz redmine-e647e99b741ce0360ee479925009076f48d0d8a5.zip |
Allow issues grouping by creation, update and closing date (#13803).
Implemented for PostgreSQL only for now.
git-svn-id: http://svn.redmine.org/redmine/trunk@17724 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/queries_helper.rb | 2 | ||||
-rw-r--r-- | app/models/issue_query.rb | 6 | ||||
-rw-r--r-- | app/models/query.rb | 20 |
3 files changed, 24 insertions, 4 deletions
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 01d10d883..261291727 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -128,7 +128,7 @@ module QueriesHelper items.each do |item| group_name = group_count = nil if query.grouped? - group = query.group_by_column.value(item) + group = query.group_by_column.group_value(item) if first || group != previous_group if group.blank? && group != false group_name = "(#{l(:label_blank_value)})" diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 0f2b8e2bd..2e01507ac 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -30,7 +30,7 @@ class IssueQuery < Query QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"), QueryColumn.new(:author, :sortable => lambda {User.fields_for_order_statement("authors")}, :groupable => true), QueryColumn.new(:assigned_to, :sortable => lambda {User.fields_for_order_statement}, :groupable => true), - QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'), + TimestampQueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc', :groupable => true), QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true), QueryColumn.new(:fixed_version, :sortable => lambda {Version.fields_for_order_statement}, :groupable => true), QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date", :groupable => true), @@ -41,8 +41,8 @@ class IssueQuery < Query " WHERE subtasks.root_id = #{Issue.table_name}.root_id AND subtasks.lft >= #{Issue.table_name}.lft AND subtasks.rgt <= #{Issue.table_name}.rgt), 0)", :default_order => 'desc'), QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio", :groupable => true), - QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'), - QueryColumn.new(:closed_on, :sortable => "#{Issue.table_name}.closed_on", :default_order => 'desc'), + TimestampQueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc', :groupable => true), + TimestampQueryColumn.new(:closed_on, :sortable => "#{Issue.table_name}.closed_on", :default_order => 'desc', :groupable => true), QueryColumn.new(:last_updated_by, :sortable => lambda {User.fields_for_order_statement("last_journal_user")}), QueryColumn.new(:relations, :caption => :label_related_issues), QueryColumn.new(:attachments, :caption => :label_attachment_plural), diff --git a/app/models/query.rb b/app/models/query.rb index 1e8080b86..1aa09d2a2 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -71,11 +71,31 @@ class QueryColumn object.send name end + # Returns the group that object belongs to when grouping query results + def group_value(object) + value(object) + end + def css_classes name end end +class TimestampQueryColumn < QueryColumn + + def groupable + if @groupable + Redmine::Database.timestamp_to_date(sortable, User.current.time_zone) + end + end + + def group_value(object) + if time = value(object) + User.current.time_to_date(time) + end + end +end + class QueryAssociationColumn < QueryColumn def initialize(association, attribute, options={}) |