Skip to content

Commit

Permalink
don't count clients and providers deleted the year they were created. #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Dec 28, 2018
1 parent df42577 commit b09b77e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions app/models/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,12 @@ def year
created_at.year if created_at.present?
end

# count years account has been active. Ignore if deleted the same year as created
def cumulative_years
if deleted_at
(created_at.year..[created_at.year, deleted_at.year - 1].max).to_a
if deleted_at && deleted_at.year > created_at.year
(created_at.year..deleted_at.year).to_a
elsif deleted_at
[]
else
(created_at.year..Date.today.year).to_a
end
Expand Down
7 changes: 5 additions & 2 deletions app/models/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,12 @@ def year
joined.year if joined.present?
end

# count years account has been active. Ignore if deleted the same year as created
def cumulative_years
if deleted_at
(created_at.year..[created_at.year, deleted_at.year - 1].max).to_a
if deleted_at && deleted_at.year > created_at.year
(created_at.year..deleted_at.year).to_a
elsif deleted_at
[]
else
(created_at.year..Date.today.year).to_a
end
Expand Down

0 comments on commit b09b77e

Please sign in to comment.