# HG changeset patch # User neko259 # Date 2014-01-28 12:56:17 # Node ID f8272ced8595e2fc7369bb3dd53dc992ca8f8efb # Parent 15bd4a697e467ea4c5cd6d9254db6cef7192e1b8 Changed tag popularity algorithm again a bit, now popularity is relative diff --git a/boards/models/tag.py b/boards/models/tag.py --- a/boards/models/tag.py +++ b/boards/models/tag.py @@ -1,4 +1,4 @@ -from boards.models import Thread +from boards.models import Thread, Post from django.db import models from django.db.models import Count @@ -47,17 +47,14 @@ class Tag(models.Model): return self.threads.count() def get_popularity(self): - popularity = 0.0 + all_post_count = Post.objects.all().count() + + tag_reply_count = 0.0 for thread in self.threads.all(): - reply_count = thread.get_reply_count() + tag_reply_count += thread.get_reply_count() - thread_popularity = 0.0 - thread_popularity += REPLY_POPULARITY * reply_count - thread_popularity += OPENING_POST_POPULARITY - if thread.archived: - thread_popularity *= ARCHIVE_POPULARITY_MODIFIER - popularity += thread_popularity + popularity = tag_reply_count / all_post_count return popularity