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

View File

@ -1254,11 +1254,11 @@ where id = ?
# 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."
lf = conf["leechFails"]
if not lf:
return None
return False
# if over threshold or every half threshold reps after that
if card.lapses >= lf and (card.lapses - lf) % (max(lf // 2, 1)) == 0:
# add a leech tag
@ -1272,7 +1272,7 @@ where id = ?
# notify UI
hooks.card_did_leech(card)
return True
return None
return False
# Tools
##########################################################################