From ef2f6910e6037057deeef3c9a1ca1602339fc797 Mon Sep 17 00:00:00 2001 From: Lili Date: Fri, 13 Jan 2023 11:04:01 +0100 Subject: [PATCH] add a refresh+clear command --- tlapbot/__init__.py | 1 + tlapbot/db.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/tlapbot/__init__.py b/tlapbot/__init__.py index e1c619f..4bc5e57 100644 --- a/tlapbot/__init__.py +++ b/tlapbot/__init__.py @@ -51,6 +51,7 @@ def create_app(test_config=None): db.init_app(app) app.cli.add_command(db.clear_queue_command) app.cli.add_command(db.refresh_counters_command) + app.cli.add_command(db.refresh_and_clear_command) # scheduler job for giving points to users def proxy_job(): diff --git a/tlapbot/db.py b/tlapbot/db.py index 21aec9e..428c9b9 100644 --- a/tlapbot/db.py +++ b/tlapbot/db.py @@ -106,6 +106,15 @@ def refresh_counters_command(): click.echo('Counters refreshed.') +@click.command('clear-refresh') +@with_appcontext +def refresh_and_clear_command(): + """Refresh counters and clear queue.""" + refresh_counters() + clear_redeem_queue() + click.echo('Counters refreshed and queue cleared.') + + def init_app(app): app.teardown_appcontext(close_db) app.cli.add_command(init_db_command)