2022-06-07 10:57:26 +00:00
|
|
|
from files.cli import g, app, db_session
|
|
|
|
import click
|
2022-06-07 12:31:24 +00:00
|
|
|
import files.helpers.const as const
|
2022-06-07 11:36:55 +00:00
|
|
|
import files.helpers.lottery as lottery
|
2022-06-07 12:31:24 +00:00
|
|
|
import files.helpers.stats as stats
|
2022-06-07 10:57:26 +00:00
|
|
|
|
|
|
|
@app.cli.command('cron', help='Run scheduled tasks.')
|
|
|
|
@click.option('--every-5m', is_flag=True, help='Call every 5 minutes.')
|
|
|
|
@click.option('--every-1h', is_flag=True, help='Call every 1 hour.')
|
|
|
|
@click.option('--every-1d', is_flag=True, help='Call every 1 day.')
|
|
|
|
def cron(every_5m, every_1h, every_1d):
|
|
|
|
g.db = db_session()
|
|
|
|
|
|
|
|
if every_5m:
|
2022-06-07 11:36:55 +00:00
|
|
|
lottery.check_if_end_lottery_task()
|
2022-06-07 12:31:24 +00:00
|
|
|
|
2022-06-07 10:57:26 +00:00
|
|
|
if every_1h:
|
|
|
|
pass
|
2022-06-07 12:31:24 +00:00
|
|
|
|
2022-06-07 10:57:26 +00:00
|
|
|
if every_1d:
|
2022-06-07 12:31:24 +00:00
|
|
|
stats.generate_charts_task(const.SITE)
|
2022-06-07 10:57:26 +00:00
|
|
|
|