Skip to content

Commit

Permalink
Added done_ratio calcualte from TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
zigzag committed Jan 26, 2010
1 parent 773f3fd commit dcfdc25
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/redmine_subtasks/redmine_ext/issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ def move_to(new_project, new_tracker = nil, options = {})

def done_ratio
if leaf?
read_attribute(:done_ratio)
insight = todo_hours + spent_hours
return 0 if (insight == 0)
100 - (todo_hours / insight * 100).to_i
else
@total_planned_days ||= 0
@total_actual_days ||= 0
Expand Down Expand Up @@ -248,6 +250,13 @@ def estimated_hours_with_subtasks=( h)
def duration1
(start_date && due_date) ? (due_date - start_date + 1) : 0
end

def todo_hours
return @todo_hours if @todo_hours
last_entry = time_entries.sort_by(&:spent_on).sort_by(&:updated_on).last
last_todo_wrapper = last_entry.custom_value_for(CustomField.find_by_name('TODO').id) if last_entry
@todo_hours = (last_todo_wrapper ? last_todo_wrapper.value.to_f : estimated_hours) || 0
end

end
end
Expand Down

0 comments on commit dcfdc25

Please sign in to comment.