aboutsummaryrefslogtreecommitdiff
path: root/app/models.py
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2018-09-03 01:49:57 +0100
committerrubenwardy <rw@rubenwardy.com>2018-09-03 01:50:53 +0100
commited409df3235f63f6c15ee715e5e10ee27219cf16 (patch)
tree1f4a52479b80497a82a171662cdae4e6bb1eee3c /app/models.py
parentb8decafd752bc6257d71d1204791727c6a291db0 (diff)
downloadcheatdb-ed409df3235f63f6c15ee715e5e10ee27219cf16.tar.xz
Update scoring algorithm to take licenses and screenshots into accountv1.10.0
Diffstat (limited to 'app/models.py')
-rw-r--r--app/models.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/app/models.py b/app/models.py
index 2ce6647..66aa0f4 100644
--- a/app/models.py
+++ b/app/models.py
@@ -514,17 +514,21 @@ class Package(db.Model):
def recalcScore(self):
import datetime
- self.score = 0
+ self.score = 10
- if self.forums is None:
- return
+ if self.forums is not None:
+ 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)
+
+ if self.getMainScreenshotURL() is None:
+ self.score *= 0.8
- 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 / years + 80*min(6, months)
+ if not self.license.is_foss or not self.media_license.is_foss:
+ self.score *= 0.1
class MetaPackage(db.Model):
id = db.Column(db.Integer, primary_key=True)