fix checkLeech hint

This commit is contained in:
Damien Elmes 2020-01-16 07:59:57 +10:00
parent 886536d78f
commit 8cb980bacc
2 changed files with 7 additions and 5 deletions

View File

@ -1128,11 +1128,11 @@ did = ?, queue = %s, due = ?, usn = ? where id = ?"""
# Leeches # Leeches
########################################################################## ##########################################################################
def _checkLeech(self, card, conf): def _checkLeech(self, card, conf) -> bool:
"Leech handler. True if card was a leech." "Leech handler. True if card was a leech."
lf = conf["leechFails"] lf = conf["leechFails"]
if not lf: if not lf:
return return False
# if over threshold or every half threshold reps after that # if over threshold or every half threshold reps after that
if card.lapses >= lf and (card.lapses - lf) % (max(lf // 2, 1)) == 0: if card.lapses >= lf and (card.lapses - lf) % (max(lf // 2, 1)) == 0:
# add a leech tag # add a leech tag
@ -1152,6 +1152,8 @@ did = ?, queue = %s, due = ?, usn = ? where id = ?"""
# notify UI # notify UI
hooks.card_did_leech(card) hooks.card_did_leech(card)
return True return True
else:
return False
# Tools # Tools
########################################################################## ##########################################################################

View File

@ -1254,11 +1254,11 @@ where id = ?
# Leeches # Leeches
########################################################################## ##########################################################################
def _checkLeech(self, card: Card, conf: Dict[str, Any]) -> Optional[bool]: def _checkLeech(self, card: Card, conf: Dict[str, Any]) -> bool:
"Leech handler. True if card was a leech." "Leech handler. True if card was a leech."
lf = conf["leechFails"] lf = conf["leechFails"]
if not lf: if not lf:
return None return False
# if over threshold or every half threshold reps after that # if over threshold or every half threshold reps after that
if card.lapses >= lf and (card.lapses - lf) % (max(lf // 2, 1)) == 0: if card.lapses >= lf and (card.lapses - lf) % (max(lf // 2, 1)) == 0:
# add a leech tag # add a leech tag
@ -1272,7 +1272,7 @@ where id = ?
# notify UI # notify UI
hooks.card_did_leech(card) hooks.card_did_leech(card)
return True return True
return None return False
# Tools # Tools
########################################################################## ##########################################################################