Improve package scoring

This commit is contained in:
rubenwardy
2019-11-21 22:16:35 +00:00
committed by GitHub
parent 94426e97aa
commit 33b2b38308
6 changed files with 55 additions and 13 deletions

View File

@@ -69,6 +69,10 @@ 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

View File

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

23
app/tasks/pkgtasks.py Normal file
View File

@@ -0,0 +1,23 @@
# Content DB
# 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/>.
from app.models import Package, PackageRelease
from app.tasks import celery
@celery.task()
def updatePackageScores():
Package.query.update({ "score": PackageRelease.score * 0.8 })