##// END OF EJS Templates
Changed tag popularity algorithm again a bit, now popularity is relative
neko259 -
r599:f8272ced default
parent child Browse files
Show More
@@ -1,4 +1,4 b''
1 from boards.models import Thread
1 from boards.models import Thread, Post
2 from django.db import models
2 from django.db import models
3 from django.db.models import Count
3 from django.db.models import Count
4
4
@@ -47,17 +47,14 b' class Tag(models.Model):'
47 return self.threads.count()
47 return self.threads.count()
48
48
49 def get_popularity(self):
49 def get_popularity(self):
50 popularity = 0.0
50 all_post_count = Post.objects.all().count()
51
52 tag_reply_count = 0.0
51
53
52 for thread in self.threads.all():
54 for thread in self.threads.all():
53 reply_count = thread.get_reply_count()
55 tag_reply_count += thread.get_reply_count()
54
56
55 thread_popularity = 0.0
57 popularity = tag_reply_count / all_post_count
56 thread_popularity += REPLY_POPULARITY * reply_count
57 thread_popularity += OPENING_POST_POPULARITY
58 if thread.archived:
59 thread_popularity *= ARCHIVE_POPULARITY_MODIFIER
60 popularity += thread_popularity
61
58
62 return popularity
59 return popularity
63
60
General Comments 0
You need to be logged in to leave comments. Login now