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

@@ -75,7 +75,7 @@ def admin_page():
return redirect(url_for("admin.admin_page"))
elif action == "recalcscores":
for p in Package.query.all():
p.recalcScore()
p.setStartScore()
db.session.commit()
return redirect(url_for("admin.admin_page"))

View File

@@ -130,9 +130,18 @@ def download_release(package, id):
if not has_key(key):
set_key(key, "true")
bonus = 1
if not package.getIsFOSS():
bonus *= 0.1
PackageRelease.query.filter_by(id=release.id).update({
"downloads": PackageRelease.downloads + 1
})
Package.query.filter_by(id=package.id).update({
"score": Package.score + bonus
})
db.session.commit()
return redirect(release.url, code=300)