##// END OF EJS Templates
Small changes to the tag popularity code
neko259 -
r519:b1468c6b default
parent child Browse files
Show More
@@ -5,11 +5,11 b' from django.db.models import Count'
5 __author__ = 'neko259'
5 __author__ = 'neko259'
6
6
7 TAG_FONT_MULTIPLIER = 0.1
7 TAG_FONT_MULTIPLIER = 0.1
8 MAX_TAG_FONT = 10
8 MAX_TAG_FONT = 5
9
9
10 OPENING_POST_POPULARITY = 0.5
10 OPENING_POST_POPULARITY = 0.5
11 ARCHIVE_POPULARITY = 0.01
12 REPLY_POPULARITY = 0.1
11 REPLY_POPULARITY = 0.1
12 ARCHIVE_POPULARITY_MODIFIER = 0.1
13
13
14
14
15 class TagManager(models.Manager):
15 class TagManager(models.Manager):
@@ -52,11 +52,12 b' class Tag(models.Model):'
52 for thread in self.threads.all():
52 for thread in self.threads.all():
53 reply_count = thread.get_reply_count()
53 reply_count = thread.get_reply_count()
54
54
55 thread_popularity = 0.0
56 thread_popularity += REPLY_POPULARITY * reply_count
57 thread_popularity += OPENING_POST_POPULARITY
55 if thread.archived:
58 if thread.archived:
56 popularity += ARCHIVE_POPULARITY * reply_count
59 thread_popularity *= ARCHIVE_POPULARITY_MODIFIER
57 else:
60 popularity += thread_popularity
58 popularity += REPLY_POPULARITY * reply_count
59 popularity += OPENING_POST_POPULARITY
60
61
61 return popularity
62 return popularity
62
63
@@ -83,9 +84,8 b' class Tag(models.Model):'
83 """Get tag font value to differ most popular tags in the list"""
84 """Get tag font value to differ most popular tags in the list"""
84
85
85 popularity = self.get_popularity()
86 popularity = self.get_popularity()
86 if popularity > MAX_TAG_FONT:
87 popularity = MAX_TAG_FONT
88
87
89 font_value = str(1 + (popularity - 1) * TAG_FONT_MULTIPLIER)
88 font_value = 1 + (popularity - 1) * TAG_FONT_MULTIPLIER
89 font_value = min(font_value, MAX_TAG_FONT)
90
90
91 return font_value
91 return str(font_value)
General Comments 0
You need to be logged in to leave comments. Login now