Fix: Changes to the User table cause unavoidable breakages in the Leaderboard system.

This commit is contained in:
Ben Rog-Wilhelm 2022-11-21 09:59:08 -06:00 committed by Ben Rog-Wilhelm
parent 18437003cf
commit 7e25af2fa0
5 changed files with 14 additions and 7 deletions

View file

@ -1,11 +1,16 @@
import typing
# clean strings for searching
def sql_ilike_clean(my_str):
return my_str.replace(r'\\', '').replace('_', r'\_').replace('%', '').strip()
def bool_from_string(str_in: str) -> bool:
if str_in.lower() in ("yes", "true", "t", "1"):
# this will also just return a bool verbatim
def bool_from_string(input: typing.Union[str, bool]) -> bool:
if isinstance(input, bool):
return input
if input.lower() in ("yes", "true", "t", "on", "1"):
return True
if str_in.lower() in ("no", "false", "f", "0"):
if input.lower() in ("no", "false", "f", "off", "0"):
return False
raise ValueError()