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 14:42:24 +00:00
|
|
|
|
2022-06-07 11:36:55 +00:00
|
|
|
import files.helpers.lottery as lottery
|
2022-06-07 14:42:24 +00:00
|
|
|
import files.helpers.offsitementions as offsitementions
|
2022-06-07 12:31:24 +00:00
|
|
|
import files.helpers.stats as stats
|
2022-06-10 09:47:41 +00:00
|
|
|
import files.helpers.awards as awards
|
|
|
|
import files.routes.static as route_static
|
|
|
|
from files.routes.subs import sub_inactive_purge_task
|
2022-07-02 09:30:17 +00:00
|
|
|
from files.routes.admin import give_monthly_marseybux_task
|
2022-06-07 10:57:26 +00:00
|
|
|
|
2022-06-27 19:02:24 +00:00
|
|
|
from sys import stdout
|
|
|
|
|
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.')
|
2022-06-10 20:23:01 +00:00
|
|
|
@click.option('--every-1mo', is_flag=True, help='Call every 1 month.')
|
|
|
|
def cron(every_5m, every_1h, every_1d, every_1mo):
|
2022-06-07 10:57:26 +00:00
|
|
|
g.db = db_session()
|
|
|
|
|
|
|
|
if every_5m:
|
2022-06-07 11:36:55 +00:00
|
|
|
lottery.check_if_end_lottery_task()
|
2022-06-07 14:42:24 +00:00
|
|
|
offsitementions.offsite_mentions_task()
|
2022-06-07 12:31:24 +00:00
|
|
|
|
2022-06-07 10:57:26 +00:00
|
|
|
if every_1h:
|
2022-06-27 06:15:35 +00:00
|
|
|
awards.award_timers_bots_task()
|
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-10 09:47:41 +00:00
|
|
|
route_static.stats_cached()
|
|
|
|
sub_inactive_purge_task()
|
|
|
|
|
2022-06-10 20:23:01 +00:00
|
|
|
if every_1mo:
|
2022-07-02 09:30:17 +00:00
|
|
|
give_monthly_marseybux_task()
|
2022-06-26 05:37:36 +00:00
|
|
|
|
2022-06-27 06:15:35 +00:00
|
|
|
g.db.commit()
|
|
|
|
g.db.close()
|
2022-06-27 19:02:24 +00:00
|
|
|
stdout.flush()
|