Update scoring algorithm to take licenses and screenshots into account

This commit is contained in:
rubenwardy 2018-09-03 01:49:57 +01:00
parent b8decafd75
commit ed409df323
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C
1 changed files with 13 additions and 9 deletions

View File

@ -514,17 +514,21 @@ class Package(db.Model):
def recalcScore(self): def recalcScore(self):
import datetime import datetime
self.score = 0 self.score = 10
if self.forums is None: if self.forums is not None:
return topic = ForumTopic.query.get(self.forums)
if topic:
days = (datetime.datetime.now() - topic.created_at).days
months = days / 30
years = days / 365
self.score = topic.views / max(years, 0.0416) + 80*min(max(months, 0.5), 6)
topic = ForumTopic.query.get(self.forums) if self.getMainScreenshotURL() is None:
if topic: self.score *= 0.8
days = (datetime.datetime.now() - topic.created_at).days
months = days / 30 if not self.license.is_foss or not self.media_license.is_foss:
years = days / 365 self.score *= 0.1
self.score = topic.views / years + 80*min(6, months)
class MetaPackage(db.Model): class MetaPackage(db.Model):
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)