Add celery beat for topic import

This commit is contained in:
rubenwardy 2018-10-09 21:49:26 +01:00
parent 328d05bdf6
commit 75bab28d82
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C
3 changed files with 13 additions and 0 deletions

1
.gitignore vendored

@ -7,6 +7,7 @@ log.txt
*.rdb *.rdb
uploads uploads
thumbnails thumbnails
celerybeat-schedule
# Created by https://www.gitignore.io/api/linux,macos,python,windows # Created by https://www.gitignore.io/api/linux,macos,python,windows

@ -18,6 +18,7 @@
import flask import flask
from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.sqlalchemy import SQLAlchemy
from celery import Celery from celery import Celery
from celery.schedules import crontab
from app import app from app import app
from app.models import * from app.models import *
@ -64,4 +65,12 @@ def make_celery(app):
celery = make_celery(app) celery = make_celery(app)
CELERYBEAT_SCHEDULE = {
'topic_list_import': {
'task': 'app.tasks.forumtasks.importTopicList',
'schedule': crontab(minute=1, hour=1),
}
}
celery.conf.beat_schedule = CELERYBEAT_SCHEDULE
from . import importtasks, forumtasks, emails from . import importtasks, forumtasks, emails

@ -138,4 +138,7 @@ def importTopicList():
topic.views = info["views"] topic.views = info["views"]
topic.created_at = info["date"] topic.created_at = info["date"]
for p in Package.query.all():
p.recalcScore()
db.session.commit() db.session.commit()