Skip to content

Commit

Permalink
Make maybe_apply always return an int
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiesel committed Mar 26, 2020
1 parent 22c7cd6 commit a189bf0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib/review_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def check_for_straight_reward(_reviewer, card, answer: Answer):

easeplus = maybe_apply_reward(sett, straightlen, card)

if easeplus:
if easeplus > 0:
latest_info[card.id] = easeplus

if sett.enable_notifications:
Expand Down
2 changes: 1 addition & 1 deletion src/lib/sync_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def after_sync(col) -> None:

result = check_cids(col, newrev_cids)

filtered_logs = [f"cid:{r[0]} easeplus:{r[1]}" for r in result if r[1] != 0]
filtered_logs = [f"cid:{r[0]} easeplus:{r[1]}" for r in result if r[1] > 0]
filtered_length = len(filtered_logs)

if filtered_length > 0:
Expand Down
4 changes: 2 additions & 2 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def apply_ease_change(card, reward: int, sett_min: int, sett_max: int):
else:
return 0

def maybe_apply_reward(sett, straightlen, card) -> Optional[Tuple[int, int]]:
def maybe_apply_reward(sett, straightlen, card) -> int:
if (
sett.straight_length >= 1 and
straightlen >= sett.straight_length
Expand All @@ -87,4 +87,4 @@ def maybe_apply_reward(sett, straightlen, card) -> Optional[Tuple[int, int]]:
# easeplus of 0 will react similiar to None
return easeplus

return None
return 0

0 comments on commit a189bf0

Please # to comment.