|
@@
-16,7
+16,7
|
|
16
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
16
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
17
|
|
|
17
|
|
|
18
|
class QueryColumn
|
|
18
|
class QueryColumn
|
|
19
|
attr_accessor :name, :sortable, :groupable, :default_order, :include_options
|
|
19
|
attr_accessor :name, :sortable, :groupable, :default_order
|
|
20
|
include Redmine::I18n
|
|
20
|
include Redmine::I18n
|
|
21
|
|
|
21
|
|
|
22
|
def initialize(name, options={})
|
|
22
|
def initialize(name, options={})
|
|
@@
-27,7
+27,6
class QueryColumn
|
|
27
|
self.groupable = name.to_s
|
|
27
|
self.groupable = name.to_s
|
|
28
|
end
|
|
28
|
end
|
|
29
|
self.default_order = options[:default_order]
|
|
29
|
self.default_order = options[:default_order]
|
|
30
|
self.include_options = options[:include]
|
|
|
|
|
31
|
end
|
|
30
|
end
|
|
32
|
|
|
31
|
|
|
33
|
def caption
|
|
32
|
def caption
|
|
@@
-49,7
+48,6
class QueryCustomFieldColumn < QueryColumn
|
|
49
|
self.groupable = custom_field.order_statement
|
|
48
|
self.groupable = custom_field.order_statement
|
|
50
|
end
|
|
49
|
end
|
|
51
|
self.groupable ||= false
|
|
50
|
self.groupable ||= false
|
|
52
|
self.include_options = :custom_values
|
|
|
|
|
53
|
@cf = custom_field
|
|
51
|
@cf = custom_field
|
|
54
|
end
|
|
52
|
end
|
|
55
|
|
|
53
|
|
|
@@
-109,15
+107,15
class Query < ActiveRecord::Base
|
|
109
|
|
|
107
|
|
|
110
|
@@available_columns = [
|
|
108
|
@@available_columns = [
|
|
111
|
QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true),
|
|
109
|
QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true),
|
|
112
|
QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position", :groupable => true, :include => :tracker),
|
|
110
|
QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position", :groupable => true),
|
|
113
|
QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position", :groupable => true),
|
|
111
|
QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position", :groupable => true),
|
|
114
|
QueryColumn.new(:priority, :sortable => "#{IssuePriority.table_name}.position", :default_order => 'desc', :groupable => true),
|
|
112
|
QueryColumn.new(:priority, :sortable => "#{IssuePriority.table_name}.position", :default_order => 'desc', :groupable => true),
|
|
115
|
QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"),
|
|
113
|
QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"),
|
|
116
|
QueryColumn.new(:author),
|
|
114
|
QueryColumn.new(:author),
|
|
117
|
QueryColumn.new(:assigned_to, :sortable => ["#{User.table_name}.lastname", "#{User.table_name}.firstname", "#{User.table_name}.id"], :groupable => true, :include => :assigned_to),
|
|
115
|
QueryColumn.new(:assigned_to, :sortable => ["#{User.table_name}.lastname", "#{User.table_name}.firstname", "#{User.table_name}.id"], :groupable => true),
|
|
118
|
QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'),
|
|
116
|
QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'),
|
|
119
|
QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true, :include => :category),
|
|
117
|
QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true),
|
|
120
|
QueryColumn.new(:fixed_version, :sortable => ["#{Version.table_name}.effective_date", "#{Version.table_name}.name"], :default_order => 'desc', :groupable => true, :include => :fixed_version),
|
|
118
|
QueryColumn.new(:fixed_version, :sortable => ["#{Version.table_name}.effective_date", "#{Version.table_name}.name"], :default_order => 'desc', :groupable => true),
|
|
121
|
QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"),
|
|
119
|
QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"),
|
|
122
|
QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"),
|
|
120
|
QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"),
|
|
123
|
QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"),
|
|
121
|
QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"),
|
|
@@
-324,10
+322,6
class Query < ActiveRecord::Base
|
|
324
|
def group_by_statement
|
|
322
|
def group_by_statement
|
|
325
|
group_by_column.groupable
|
|
323
|
group_by_column.groupable
|
|
326
|
end
|
|
324
|
end
|
|
327
|
|
|
|
|
|
328
|
def include_options
|
|
|
|
|
329
|
(columns << group_by_column).collect {|column| column && column.include_options}.flatten.compact.uniq
|
|
|
|
|
330
|
end
|
|
|
|
|
331
|
|
|
325
|
|
|
332
|
def project_statement
|
|
326
|
def project_statement
|
|
333
|
project_clauses = []
|
|
327
|
project_clauses = []
|