Skip to content

Commit 6e6372d

Browse files
committed
mostly_bad shouldn't match for movies w/ 1 score
1 parent abe6d1c commit 6e6372d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

spec/recommender_spec.cr

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ SAMPLES = [
109109
"61/100",
110110
"Meh. This seems to be ok, but it probably won't change your life.",
111111
],
112+
[
113+
"Wander",
114+
nil,
115+
nil,
116+
"5.0",
117+
nil,
118+
"Meh. This seems to be ok, but it probably won't change your life.",
119+
],
112120
[
113121
"Grudge Match",
114122
"31%",
@@ -133,6 +141,14 @@ SAMPLES = [
133141
"9/100",
134142
"Be prepared for something awful.",
135143
],
144+
[
145+
"Breach",
146+
nil,
147+
nil,
148+
"2.7",
149+
nil,
150+
"Be prepared for something awful.",
151+
],
136152
[
137153
"Terminator 3: Rise of the Machines",
138154
"69%",

src/recommender.cr

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ class Recommender
1414
@minor_count = (@scores.size * 0.25).round.to_i
1515
end
1616

17+
def single_score?
18+
@scores.size == 1
19+
end
20+
1721
# ameba:disable Metrics/CyclomaticComplexity
1822
def run
1923
text, emoji =
@@ -35,10 +39,10 @@ class Recommender
3539
["You may enjoy this. It could also be boring though.", ":ok_hand:"]
3640
elsif unanimously_average?
3741
["Meh. This seems to be ok, but it probably won't change your life.", ":partly_sunny:"]
38-
elsif mostly_bad?
39-
["Please move along. There's nothing to see here.", ":anguished:"]
4042
elsif unanimously_bad?
4143
["Be prepared for something awful.", ":-1:"]
44+
elsif mostly_bad?
45+
["Please move along. There's nothing to see here.", ":anguished:"]
4246
elsif mostly_average_or_bad?
4347
["This seems to be rather something that's not actually good.", ":sleeping:"]
4448
else
@@ -67,6 +71,8 @@ class Recommender
6771
end
6872

6973
def controversially_excellent?
74+
return false if single_score?
75+
7076
excellent_count = scores.count(&.excellent?)
7177

7278
bad_count = scores.count(&.bad?)

0 commit comments

Comments
 (0)