mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Add score bonus to reviews
This commit is contained in:
parent
d0aecd0ee5
commit
ac7adde4b1
@ -87,7 +87,7 @@ def admin_page():
|
||||
return redirect(url_for("admin.admin_page"))
|
||||
elif action == "recalcscores":
|
||||
for p in Package.query.all():
|
||||
p.setStartScore()
|
||||
p.recalcScore()
|
||||
|
||||
db.session.commit()
|
||||
return redirect(url_for("admin.admin_page"))
|
||||
|
@ -42,8 +42,7 @@ def package_scores():
|
||||
qb = QueryBuilder(request.args)
|
||||
query = qb.buildPackageQuery()
|
||||
|
||||
pkgs = [{ "author": package.author.username, "name": package.name, "score": package.score } \
|
||||
for package in query.all()]
|
||||
pkgs = [package.getScoreDict() for package in query.all()]
|
||||
return jsonify(pkgs)
|
||||
|
||||
|
||||
|
@ -82,6 +82,8 @@ def review(package):
|
||||
|
||||
db.session.commit()
|
||||
|
||||
package.recalcScore()
|
||||
|
||||
notif_msg = None
|
||||
if was_new:
|
||||
notif_msg = "New review '{}' on package {}".format(form.title.data, package.title)
|
||||
|
@ -2,8 +2,12 @@ title: Top Packages Algorithm
|
||||
|
||||
## Score
|
||||
|
||||
A package's score is currently equal to a pseudo rolling average of downloads.
|
||||
In the future, a package will also gain score through reviews.
|
||||
A package's score is currently equal to a pseudo rolling average of downloads,
|
||||
plus the sum of review scores.
|
||||
|
||||
A review score is 100 if positive, -100 if negative.
|
||||
|
||||
score = avg_downloads + Σ 100 * (positive ? 1 : -1)
|
||||
|
||||
## Pseudo rolling average of downloads
|
||||
|
||||
@ -35,7 +39,8 @@ which was 20% of the above value.
|
||||
## Manual adjustments
|
||||
|
||||
The admin occasionally reduces all packages by a set percentage to speed up
|
||||
convergence. Convergence is when
|
||||
convergence. Convergence is when the pseudo-rolling average matches the actual
|
||||
rolling average - the effect of the legacy heuristic is gone.
|
||||
|
||||
## Transparency and Feedback
|
||||
|
||||
|
@ -712,28 +712,19 @@ class Package(db.Model):
|
||||
else:
|
||||
raise Exception("Permission {} is not related to packages".format(perm.name))
|
||||
|
||||
def setStartScore(self):
|
||||
downloads = self.downloads
|
||||
|
||||
forum_score = 0
|
||||
forum_bonus = 0
|
||||
topic = self.forums and ForumTopic.query.get(self.forums)
|
||||
if topic:
|
||||
months = (datetime.datetime.now() - topic.created_at).days / 30
|
||||
years = months / 12
|
||||
forum_score = topic.views / max(years, 0.0416) + 80*min(max(months, 0.5), 6)
|
||||
forum_bonus = topic.views + topic.posts
|
||||
|
||||
self.score = max(downloads, forum_score * 0.6) + forum_bonus
|
||||
|
||||
if self.getMainScreenshotURL() is None:
|
||||
self.score *= 0.8
|
||||
|
||||
self.recalcScore()
|
||||
def getScoreDict(self):
|
||||
return {
|
||||
"author": self.author.username,
|
||||
"name": self.name,
|
||||
"score": self.score,
|
||||
"score_downloads": self.score_downloads,
|
||||
"score_reviews": self.score - self.score_downloads,
|
||||
"downloads": self.downloads
|
||||
}
|
||||
|
||||
def recalcScore(self):
|
||||
self.score_downloads = self.score
|
||||
|
||||
review_scores = [ 100 * r.asSign() for r in self.reviews ]
|
||||
self.score = self.score_downloads + sum(review_scores)
|
||||
|
||||
|
||||
class MetaPackage(db.Model):
|
||||
@ -1134,6 +1125,9 @@ class PackageReview(db.Model):
|
||||
|
||||
thread = db.relationship("Thread", uselist=False, back_populates="review")
|
||||
|
||||
def asSign(self):
|
||||
return 1 if self.recommends else -1
|
||||
|
||||
def getEditURL(self):
|
||||
return url_for("packages.edit_review",
|
||||
author=self.package.author.username,
|
||||
|
Loading…
Reference in New Issue
Block a user