|
|
@ -7,9 +7,7 @@ from flask_sqlalchemy import SQLAlchemy |
|
|
|
from flask_limiter import Limiter |
|
|
|
from flask_limiter.util import get_remote_address |
|
|
|
from mastodon import Mastodon |
|
|
|
from apscheduler.schedulers.background import BackgroundScheduler |
|
|
|
import random |
|
|
|
import atexit |
|
|
|
from config import C |
|
|
|
WRONG_ANS_HTML = '''<html> |
|
|
|
<head> |
|
|
@ -105,17 +103,7 @@ def choose_new_next(min_like_num=10): |
|
|
|
story.tail = next_one.id |
|
|
|
next_one.is_chosen = True |
|
|
|
|
|
|
|
# 更新 story! |
|
|
|
db.session.commit() |
|
|
|
|
|
|
|
scheduler = BackgroundScheduler() |
|
|
|
for d in range(5, 15): |
|
|
|
for m in range(0, 24 * 60, C.period): |
|
|
|
scheduler.add_job(func=choose_new_next, trigger='date', run_date=datetime(2021, 11, d, m // 60, m % 60), args=[1] if app.debug else []) |
|
|
|
scheduler.start() |
|
|
|
|
|
|
|
# Shut down the scheduler when exiting the app |
|
|
|
atexit.register(lambda: scheduler.shutdown()) |
|
|
|
db.session.commit() |
|
|
|
|
|
|
|
|
|
|
|
def sample_question(qs, n=3): |
|
|
@ -210,7 +198,6 @@ def story(story_id): |
|
|
|
cs_login_url = MAST_LOGIN_URL |
|
|
|
guest_login_url = url_for('main_bp.guest_login') |
|
|
|
verify_questions = sample_question(C.verify_questions) |
|
|
|
period = C.period |
|
|
|
|
|
|
|
return render_template('story.html', **locals()) |
|
|
|
|
|
|
|