Browse Source

Revert "schedule"

This reverts commit 6bd93e1e6b.
tree
欧醚 3 years ago
parent
commit
14d077725e
4 changed files with 5 additions and 39 deletions
  1. +1
    -14
      app.py
  2. +0
    -1
      requirements.txt
  3. +2
    -1
      static/css/ordinary.css
  4. +2
    -23
      templates/story.html

+ 1
- 14
app.py View File

@ -7,9 +7,7 @@ from flask_sqlalchemy import SQLAlchemy
from flask_limiter import Limiter from flask_limiter import Limiter
from flask_limiter.util import get_remote_address from flask_limiter.util import get_remote_address
from mastodon import Mastodon from mastodon import Mastodon
from apscheduler.schedulers.background import BackgroundScheduler
import random import random
import atexit
from config import C from config import C
WRONG_ANS_HTML = '''<html> WRONG_ANS_HTML = '''<html>
<head> <head>
@ -105,17 +103,7 @@ def choose_new_next(min_like_num=10):
story.tail = next_one.id story.tail = next_one.id
next_one.is_chosen = True 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): def sample_question(qs, n=3):
@ -210,7 +198,6 @@ def story(story_id):
cs_login_url = MAST_LOGIN_URL cs_login_url = MAST_LOGIN_URL
guest_login_url = url_for('main_bp.guest_login') guest_login_url = url_for('main_bp.guest_login')
verify_questions = sample_question(C.verify_questions) verify_questions = sample_question(C.verify_questions)
period = C.period
return render_template('story.html', **locals()) return render_template('story.html', **locals())

+ 0
- 1
requirements.txt View File

@ -1,4 +1,3 @@
APScheduler~=3.8.1
Flask~=2.0.2 Flask~=2.0.2
Flask_Limiter~=1.4 Flask_Limiter~=1.4
Flask_SQLAlchemy~=2.5.1 Flask_SQLAlchemy~=2.5.1

+ 2
- 1
static/css/ordinary.css View File

@ -139,6 +139,7 @@ a:focus, .btn-link:focus {
.paragraph-list { .paragraph-list {
position: relative; position: relative;
margin: 40px 40px 30px 0; margin: 40px 40px 30px 0;
background: white;
} }
.show-mask { .show-mask {
@ -184,4 +185,4 @@ nav .page-link {
nav .page-item.active .page-link { nav .page-item.active .page-link {
background-color: #000; background-color: #000;
border-color: #000; border-color: #000;
}
}

+ 2
- 23
templates/story.html View File

@ -59,8 +59,8 @@
</div> </div>
<div class="part2" id="part2"> <div class="part2" id="part2">
<div class="paragraph-list twin front qbox part-box" style="border: 0">
<h1 style="margin: -8px -5px 20px">备选续</h1>
<div class="paragraph-list twin front part-box">
<h1 style="margin: -8px -5px 20px">备选</h1>
<span style="margin:8px" class="sort-by"> <span style="margin:8px" class="sort-by">
{% if sort_by == 'like' %} {% if sort_by == 'like' %}
<a href="?sort_by=time#part2">按时间</a> | <b>按赞数</b> <a href="?sort_by=time#part2">按时间</a> | <b>按赞数</b>
@ -211,27 +211,6 @@
$('.user-info .btn').click(check_login); $('.user-info .btn').click(check_login);
$('textarea').focus(check_login); $('textarea').focus(check_login);
function makeTimer() {
let period = $("#timeleft").data('period') * 60;
var now = new Date();
now = (Date.parse(now) / 1000);
var timeLeft = period - now % period;
var hours = Math.floor(timeLeft / 3600);
var minutes = Math.floor((timeLeft - (hours * 3600 )) / 60);
var seconds = Math.floor((timeLeft - (hours * 3600) - (minutes * 60)));
if (hours < "10") { hours = "0" + hours; }
if (minutes < "10") { minutes = "0" + minutes; }
if (seconds < "10") { seconds = "0" + seconds; }
$("#timeleft").html(`${hours}:${minutes}:${seconds}`);
}
setInterval(function() { makeTimer(); }, 1000);
</script> </script>
</html> </html>

Loading…
Cancel
Save