Fix: Changes to the User table cause unavoidable breakages in the Leaderboard system.
This commit is contained in:
parent
18437003cf
commit
7e25af2fa0
5 changed files with 14 additions and 7 deletions
|
@ -28,7 +28,7 @@ app.jinja_env.cache = {}
|
||||||
app.jinja_env.auto_reload = True
|
app.jinja_env.auto_reload = True
|
||||||
faulthandler.enable()
|
faulthandler.enable()
|
||||||
|
|
||||||
if bool_from_string(environ.get("ENFORCE_PRODUCTION", "true")) and app.config["DEBUG"]:
|
if bool_from_string(environ.get("ENFORCE_PRODUCTION", True)) and app.config["DEBUG"]:
|
||||||
raise ValueError("Debug mode is not allowed! If this is a dev environment, please set ENFORCE_PRODUCTION to false")
|
raise ValueError("Debug mode is not allowed! If this is a dev environment, please set ENFORCE_PRODUCTION to false")
|
||||||
|
|
||||||
if environ.get("SITE_ID") is None:
|
if environ.get("SITE_ID") is None:
|
||||||
|
@ -126,6 +126,7 @@ app.config['MENTION_LIMIT'] = int(environ.get('MENTION_LIMIT', 100))
|
||||||
app.config['MULTIMEDIA_EMBEDDING_ENABLED'] = environ.get('MULTIMEDIA_EMBEDDING_ENABLED', "false").lower() == "true"
|
app.config['MULTIMEDIA_EMBEDDING_ENABLED'] = environ.get('MULTIMEDIA_EMBEDDING_ENABLED', "false").lower() == "true"
|
||||||
app.config['RESULTS_PER_PAGE_COMMENTS'] = int(environ.get('RESULTS_PER_PAGE_COMMENTS',50))
|
app.config['RESULTS_PER_PAGE_COMMENTS'] = int(environ.get('RESULTS_PER_PAGE_COMMENTS',50))
|
||||||
app.config['SCORE_HIDING_TIME_HOURS'] = int(environ.get('SCORE_HIDING_TIME_HOURS'))
|
app.config['SCORE_HIDING_TIME_HOURS'] = int(environ.get('SCORE_HIDING_TIME_HOURS'))
|
||||||
|
app.config['ENABLE_SERVICES'] = bool_from_string(environ.get('ENABLE_SERVICES', False))
|
||||||
|
|
||||||
r=redis.Redis(host=environ.get("REDIS_URL", "redis://localhost"), decode_responses=True, ssl_cert_reqs=None)
|
r=redis.Redis(host=environ.get("REDIS_URL", "redis://localhost"), decode_responses=True, ssl_cert_reqs=None)
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
|
|
||||||
|
import typing
|
||||||
|
|
||||||
# clean strings for searching
|
# clean strings for searching
|
||||||
def sql_ilike_clean(my_str):
|
def sql_ilike_clean(my_str):
|
||||||
return my_str.replace(r'\\', '').replace('_', r'\_').replace('%', '').strip()
|
return my_str.replace(r'\\', '').replace('_', r'\_').replace('%', '').strip()
|
||||||
|
|
||||||
def bool_from_string(str_in: str) -> bool:
|
# this will also just return a bool verbatim
|
||||||
if str_in.lower() in ("yes", "true", "t", "1"):
|
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
|
return True
|
||||||
if str_in.lower() in ("no", "false", "f", "0"):
|
if input.lower() in ("no", "false", "f", "off", "0"):
|
||||||
return False
|
return False
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
|
|
|
@ -71,6 +71,7 @@ def leaderboard_thread():
|
||||||
db.close()
|
db.close()
|
||||||
stdout.flush()
|
stdout.flush()
|
||||||
|
|
||||||
|
if app.config["ENABLE_SERVICES"]:
|
||||||
gevent.spawn(leaderboard_thread())
|
gevent.spawn(leaderboard_thread())
|
||||||
|
|
||||||
@app.get("/@<username>/upvoters/<uid>/posts")
|
@app.get("/@<username>/upvoters/<uid>/posts")
|
||||||
|
|
|
@ -5,7 +5,7 @@ logfile=/tmp/supervisord.log
|
||||||
|
|
||||||
[program:service]
|
[program:service]
|
||||||
directory=/service
|
directory=/service
|
||||||
command=sh -c 'python3 -m flask db upgrade && WERKZEUG_DEBUG_PIN=off python3 -m flask --debug run --host=0.0.0.0 --port=80'
|
command=sh -c 'python3 -m flask db upgrade && WERKZEUG_DEBUG_PIN=off ENABLE_SERVICES=true python3 -m flask --debug run --host=0.0.0.0 --port=80'
|
||||||
stdout_logfile=/dev/stdout
|
stdout_logfile=/dev/stdout
|
||||||
stdout_logfile_maxbytes=0
|
stdout_logfile_maxbytes=0
|
||||||
stderr_logfile=/dev/stderr
|
stderr_logfile=/dev/stderr
|
||||||
|
|
|
@ -5,7 +5,7 @@ logfile=/tmp/supervisord.log
|
||||||
|
|
||||||
[program:service]
|
[program:service]
|
||||||
directory=/service
|
directory=/service
|
||||||
command=sh -c 'python3 -m flask db upgrade && gunicorn files.__main__:app -k gevent -w 1 --reload -b 0.0.0.0:80 --max-requests 1000 --max-requests-jitter 500'
|
command=sh -c 'python3 -m flask db upgrade && ENABLE_SERVICES=true gunicorn files.__main__:app -k gevent -w 1 --reload -b 0.0.0.0:80 --max-requests 1000 --max-requests-jitter 500'
|
||||||
stdout_logfile=/dev/stdout
|
stdout_logfile=/dev/stdout
|
||||||
stdout_logfile_maxbytes=0
|
stdout_logfile_maxbytes=0
|
||||||
stderr_logfile=/dev/stderr
|
stderr_logfile=/dev/stderr
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue