Project

General

Profile

Patch #1582 » add_time_spent_column_to_issues-svn_r2823.patch

Patch for r2823 without colored values in "Time spent" column - Chris Grieger, 2009-07-19 11:11

View differences:

app/helpers/issues_helper.rb (working copy)
149 149
                  l(:field_due_date),
150 150
                  l(:field_done_ratio),
151 151
                  l(:field_estimated_hours),
152
                  l(:field_spent_hours),
152 153
                  l(:field_created_on),
153 154
                  l(:field_updated_on)
154 155
                  ]
......
175 176
                  format_date(issue.due_date),
176 177
                  issue.done_ratio,
177 178
                  issue.estimated_hours.to_s.gsub('.', decimal_separator),
179
                  issue.spent_hours,
178 180
                  format_time(issue.created_on),  
179 181
                  format_time(issue.updated_on)
180 182
                  ]
app/models/issue.rb (working copy)
231 231
  #   spent_hours => 0
232 232
  #   spent_hours => 50
233 233
  def spent_hours
234
    @spent_hours ||= time_entries.sum(:hours) || 0
234
    @spent_hours ||= (time_entries.sum(:hours)*100).round.to_f / 100 || 0
235 235
  end
236 236
  
237 237
  def relations
app/models/query.rb (working copy)
111 111
    QueryColumn.new(:fixed_version, :sortable => ["#{Version.table_name}.effective_date", "#{Version.table_name}.name"], :default_order => 'desc', :groupable => true),
112 112
    QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"),
113 113
    QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"),
114
    QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"),
114
    QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours" ),
115
    QueryColumn.new(:spent_hours, :sortable => "SUM(time_entries.hours)" ),
115 116
    QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio", :groupable => true),
116 117
    QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
117 118
  ]
app/controllers/issues_controller.rb (working copy)
62 62
                           :include => [ :assigned_to, :status, :tracker, :project, :priority, :category, :fixed_version ],
63 63
                           :conditions => @query.statement,
64 64
                           :limit  =>  limit,
65
                           :offset =>  @issue_pages.current.offset
65
                           :offset =>  @issue_pages.current.offset,
66
                           :joins => 'LEFT OUTER JOIN time_entries ON issues.id = time_entries.issue_id',
67
                           :group => 'issues.id'
66 68
      respond_to do |format|
67 69
        format.html { 
68 70
          if @query.grouped?
config/locales/en.yml (working copy)
170 170
  field_author: Author
171 171
  field_created_on: Created
172 172
  field_updated_on: Updated
173
  field_spent_hours: Time Spent
173 174
  field_field_format: Format
174 175
  field_is_for_all: For all projects
175 176
  field_possible_values: Possible values
(3-3/6)