]> git.lizzy.rs Git - cheatdb.git/blobdiff - app/tasks/__init__.py
Update meta on release import
[cheatdb.git] / app / tasks / __init__.py
index c431fae718a716e5ef62f3486811b4ec60dc6564..afd4300e7e43e05b90bb7032d68be6a4881f6144 100644 (file)
@@ -1,9 +1,33 @@
+# ContentDB
+# Copyright (C) 2018  rubenwardy
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+
 import flask
-from flask.ext.sqlalchemy import SQLAlchemy
+from flask_sqlalchemy import SQLAlchemy
 from celery import Celery
+from celery.schedules import crontab
 from app import app
 from app.models import *
 
+class TaskError(Exception):
+       def __init__(self, value):
+               self.value = value
+       def __str__(self):
+               return repr("TaskError: " + self.value)
+
 class FlaskCelery(Celery):
        def __init__(self, *args, **kwargs):
                super(FlaskCelery, self).__init__(*args, **kwargs)
@@ -41,4 +65,16 @@ def make_celery(app):
 
 celery = make_celery(app)
 
-from . import importtasks
+CELERYBEAT_SCHEDULE = {
+       'topic_list_import': {
+               'task': 'app.tasks.forumtasks.importTopicList',
+               'schedule': crontab(minute=1, hour=1),
+       },
+       'package_score_update': {
+               'task': 'app.tasks.pkgtasks.updatePackageScores',
+               'schedule': crontab(minute=10, hour=1),
+       }
+}
+celery.conf.beat_schedule = CELERYBEAT_SCHEDULE
+
+from . import importtasks, forumtasks, emails, pkgtasks