Module: Milestoneish

Included in:
GlobalMilestone, Milestone
Defined in:
app/models/concerns/milestoneish.rb

Instance Method Summary collapse

Instance Method Details

#closed_items_count(user = nil) ⇒ Object


2
3
4
# File 'app/models/concerns/milestoneish.rb', line 2

def closed_items_count(user = nil)
  issues_visible_to_user(user).closed.size + merge_requests.closed_and_merged.size
end

#complete?(user = nil) ⇒ Boolean

Returns:

  • (Boolean)

10
11
12
# File 'app/models/concerns/milestoneish.rb', line 10

def complete?(user = nil)
  total_items_count(user) > 0 && total_items_count(user) == closed_items_count(user)
end

#issues_visible_to_user(user = nil) ⇒ Object


26
27
28
# File 'app/models/concerns/milestoneish.rb', line 26

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

#percent_complete(user = nil) ⇒ Object


14
15
16
17
18
# File 'app/models/concerns/milestoneish.rb', line 14

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

#remaining_daysObject


20
21
22
23
24
# File 'app/models/concerns/milestoneish.rb', line 20

def remaining_days
  return 0 if !due_date || expired?

  (due_date - Date.today).to_i
end

#total_items_count(user = nil) ⇒ Object


6
7
8
# File 'app/models/concerns/milestoneish.rb', line 6

def total_items_count(user = nil)
  issues_visible_to_user(user).size + merge_requests.size
end