summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/issue_query.rb6
-rw-r--r--app/models/query.rb20
2 files changed, 23 insertions, 3 deletions
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={})