Mercurial > hg > soundsoftware-site
comparison lib/redmine/helpers/time_report.rb @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | e248c7af89ec |
children |
comparison
equal
deleted
inserted
replaced
1516:b450a9d58aed | 1517:dffacf8a6908 |
---|---|
43 | 43 |
44 def run | 44 def run |
45 unless @criteria.empty? | 45 unless @criteria.empty? |
46 time_columns = %w(tyear tmonth tweek spent_on) | 46 time_columns = %w(tyear tmonth tweek spent_on) |
47 @hours = [] | 47 @hours = [] |
48 @scope.sum(:hours, | 48 @scope.includes(:issue, :activity). |
49 :include => [:issue, :activity], | 49 group(@criteria.collect{|criteria| @available_criteria[criteria][:sql]} + time_columns). |
50 :group => @criteria.collect{|criteria| @available_criteria[criteria][:sql]} + time_columns, | 50 joins(@criteria.collect{|criteria| @available_criteria[criteria][:joins]}.compact). |
51 :joins => @criteria.collect{|criteria| @available_criteria[criteria][:joins]}.compact).each do |hash, hours| | 51 sum(:hours).each do |hash, hours| |
52 h = {'hours' => hours} | 52 h = {'hours' => hours} |
53 (@criteria + time_columns).each_with_index do |name, i| | 53 (@criteria + time_columns).each_with_index do |name, i| |
54 h[name] = hash[i] | 54 h[name] = hash[i] |
55 end | 55 end |
56 @hours << h | 56 @hours << h |
135 custom_fields += (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields) | 135 custom_fields += (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields) |
136 # Add time entry activity custom fields | 136 # Add time entry activity custom fields |
137 custom_fields += TimeEntryActivityCustomField.all | 137 custom_fields += TimeEntryActivityCustomField.all |
138 | 138 |
139 # Add list and boolean custom fields as available criteria | 139 # Add list and boolean custom fields as available criteria |
140 custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf| | 140 custom_fields.select {|cf| %w(list bool).include?(cf.field_format) && !cf.multiple?}.each do |cf| |
141 @available_criteria["cf_#{cf.id}"] = {:sql => "#{cf.join_alias}.value", | 141 @available_criteria["cf_#{cf.id}"] = {:sql => cf.group_statement, |
142 :joins => cf.join_for_order_statement, | 142 :joins => cf.join_for_order_statement, |
143 :format => cf.field_format, | 143 :format => cf.field_format, |
144 :custom_field => cf, | |
144 :label => cf.name} | 145 :label => cf.name} |
145 end | 146 end |
146 | 147 |
147 @available_criteria | 148 @available_criteria |
148 end | 149 end |