Skip to content

Commit c7aafbb

Browse files
authored
fix(Dr. Rai Reports): Fix early return (#5696)
**Story card:** [sc-16738](https://app.shortcut.com/simpledotorg/story/16738/handle-null-case-for-indicator-datasource) ## Because The early return was not properly written ```ruby def something flag: false 0 if flag calculate! end ``` This :point-up: is the original form of the method; which is wrong. The intention is to return early. ## This addresses Returning early where necessary ## Test instructions suite tests
1 parent bf02150 commit c7aafbb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

app/models/dr_rai/indicator.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,24 @@ def target_type
5252
end
5353

5454
def numerator(region, the_period = period, with_non_contactable: nil)
55-
0 unless is_supported?(region)
55+
return 0 unless is_supported?(region)
5656
numerators(region, all: with_non_contactable)[the_period]
5757
end
5858

5959
def denominator(region, the_period = period, with_non_contactable: nil)
60-
0 unless is_supported?(region)
60+
return 0 unless is_supported?(region)
6161
denominators(region, all: with_non_contactable)[the_period]
6262
end
6363

6464
def numerators(region, all: nil)
65-
[] unless is_supported?(region)
65+
return [] unless is_supported?(region)
6666
datasource(region).map do |t, data|
6767
[t, data[numerator_key(all: all)]]
6868
end.to_h
6969
end
7070

7171
def denominators(region, all: nil)
72-
[] unless is_supported?(region)
72+
return [] unless is_supported?(region)
7373
datasource(region).map do |t, data|
7474
[t, data[denominator_key(all: all)]]
7575
end.to_h

0 commit comments

Comments
 (0)