BigW Consortium Gitlab

milestoneish.rb 671 Bytes
Newer Older
1
module Milestoneish
2 3
  def closed_items_count(user = nil)
    issues_visible_to_user(user).closed.size + merge_requests.closed_and_merged.size
4 5
  end

6 7
  def total_items_count(user = nil)
    issues_visible_to_user(user).size + merge_requests.size
8 9
  end

10 11
  def complete?(user = nil)
    total_items_count(user) == closed_items_count(user)
12 13
  end

14 15
  def percent_complete(user = nil)
    ((closed_items_count(user) * 100) / total_items_count(user)).abs
16 17 18 19 20 21 22 23 24
  rescue ZeroDivisionError
    0
  end

  def remaining_days
    return 0 if !due_date || expired?

    (due_date - Date.today).to_i
  end
25 26 27 28

  def issues_visible_to_user(user = nil)
    issues.visible_to_user(user)
  end
29
end