Skip to content

Commit 39d728f

Browse files
committed
Deduplicates calculation of health from a score
1 parent 3dabe29 commit 39d728f

File tree

6 files changed

+7
-42
lines changed

6 files changed

+7
-42
lines changed

app/controllers/dashboard_controller.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,7 @@ def calculate_system_health
8686

8787
average = health_values.sum(0.0) / health_values.length
8888

89-
if average > 0.5
90-
:on_track
91-
elsif average <= -0.5
92-
:off_track
93-
else
94-
:at_risk
95-
end
89+
HealthRollup.health_from_score(average)
9690
end
9791

9892
def build_team_data(teams)

lib/domain/dashboard/system_trend_service.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,7 @@ def week_start_for(date)
6969
end
7070

7171
def score_to_health(score)
72-
if score > 0.5
73-
:on_track
74-
elsif score <= -0.5
75-
:off_track
76-
else
77-
:at_risk
78-
end
72+
HealthRollup.health_from_score(score)
7973
end
8074

8175
def weeks_of_data

lib/domain/initiatives/initiative_trend_service.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,7 @@ def week_start_for(date)
6767
end
6868

6969
def score_to_health(score)
70-
if score > 0.5
71-
:on_track
72-
elsif score <= -0.5
73-
:off_track
74-
else
75-
:at_risk
76-
end
70+
HealthRollup.health_from_score(score)
7771
end
7872

7973
def weeks_of_data

lib/domain/projects/project_trend_service.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,7 @@ def week_start_for(date)
8888
end
8989

9090
def score_to_health(score)
91-
if score > 0.5
92-
:on_track
93-
elsif score <= -0.5
94-
:off_track
95-
else
96-
:at_risk
97-
end
91+
HealthRollup.health_from_score(score)
9892
end
9993

10094
def weeks_of_data

lib/domain/teams/team.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,8 @@ def health
3434
return :not_available if health_values.empty?
3535

3636
average = health_values.sum(0.0) / health_values.length
37-
if average > 0.5
38-
:on_track
39-
elsif average <= -0.5
40-
:off_track
41-
else
42-
:at_risk
43-
end
37+
38+
HealthRollup.health_from_score(average)
4439
end
4540

4641
def health_raw_score

lib/domain/teams/team_trend_service.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,7 @@ def week_start_for(date)
6666
end
6767

6868
def score_to_health(score)
69-
if score > 0.5
70-
:on_track
71-
elsif score <= -0.5
72-
:off_track
73-
else
74-
:at_risk
75-
end
69+
HealthRollup.health_from_score(score)
7670
end
7771

7872
def weeks_of_data

0 commit comments

Comments
 (0)