Show More
@@ -41,9 +41,9 b' class Tag(models.Model):' | |||
|
41 | 41 | return self.name |
|
42 | 42 | |
|
43 | 43 | def is_empty(self): |
|
44 |
return self.get_ |
|
|
44 | return self.get_thread_count() == 0 | |
|
45 | 45 | |
|
46 |
def get_ |
|
|
46 | def get_thread_count(self): | |
|
47 | 47 | return self.threads.count() |
|
48 | 48 | |
|
49 | 49 | def get_popularity(self): |
@@ -51,13 +51,9 b' class Tag(models.Model):' | |||
|
51 | 51 | |
|
52 | 52 | tag_reply_count = 0.0 |
|
53 | 53 | |
|
54 | for thread in self.threads.all(): | |
|
55 | if thread.archived: | |
|
56 |
|
|
|
57 | else: | |
|
58 | modifier = 1 | |
|
59 | tag_reply_count += thread.get_reply_count() * modifier \ | |
|
60 | / thread.tags.all().count() | |
|
54 | tag_reply_count += self.get_post_count() | |
|
55 | tag_reply_count +=\ | |
|
56 | self.get_post_count(archived=True) * ARCHIVE_POPULARITY_MODIFIER | |
|
61 | 57 | |
|
62 | 58 | popularity = tag_reply_count / all_post_count |
|
63 | 59 | |
@@ -92,3 +88,12 b' class Tag(models.Model):' | |||
|
92 | 88 | font_value = min(font_value, MAX_TAG_FONT) |
|
93 | 89 | |
|
94 | 90 | return str(font_value) |
|
91 | ||
|
92 | def get_post_count(self, archived=False): | |
|
93 | posts_count = 0 | |
|
94 | ||
|
95 | for thread in self.threads.annotate(Count('replies')).filter( | |
|
96 | archived=archived): | |
|
97 | posts_count += thread.replies__count | |
|
98 | ||
|
99 | return posts_count |
General Comments 0
You need to be logged in to leave comments.
Login now