Adjust score given on downloads

This commit is contained in:
rubenwardy 2022-11-06 19:44:36 +00:00
parent 0cb220acff
commit 53601b77c8

@ -115,13 +115,18 @@ def download_release(package, id):
ip = request.headers.get("X-Forwarded-For") or request.remote_addr ip = request.headers.get("X-Forwarded-For") or request.remote_addr
if ip is not None and not is_user_bot(): if ip is not None and not is_user_bot():
is_minetest = (request.headers.get("User-Agent") or "").startswith("Minetest") is_minetest = (request.headers.get("User-Agent") or "").startswith("Minetest")
PackageDailyStats.update(package, is_minetest, request.args.get("reason")) reason = request.args.get("reason")
PackageDailyStats.update(package, is_minetest, reason)
key = make_download_key(ip, release.package) key = make_download_key(ip, release.package)
if not has_key(key): if not has_key(key):
set_key(key, "true") set_key(key, "true")
bonus = 0
if reason == "new":
bonus = 1 bonus = 1
elif reason == "dependency" or reason == "update":
bonus = 0.5
PackageRelease.query.filter_by(id=release.id).update({ PackageRelease.query.filter_by(id=release.id).update({
"downloads": PackageRelease.downloads + 1 "downloads": PackageRelease.downloads + 1