summaryrefslogtreecommitdiff
path: root/app/models/concerns/milestoneish.rb
blob: d67df7c1d9c1933592f0ceebb40ebdd6f0af3b61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Milestoneish
  def closed_items_count
    issues.closed.size + merge_requests.closed_and_merged.size
  end

  def total_items_count
    issues.size + merge_requests.size
  end

  def complete?
    total_items_count == closed_items_count
  end

  def percent_complete
    ((closed_items_count * 100) / total_items_count).abs
  rescue ZeroDivisionError
    0
  end

  def remaining_days
    return 0 if !due_date || expired?

    (due_date - Date.today).to_i
  end
end