##// END OF EJS Templates
Cache tag post count
neko259 -
r973:110ab3b8 default
parent child Browse files
Show More
@@ -4,6 +4,7 b' from django.db.models import Count'
4 from django.core.urlresolvers import reverse
4 from django.core.urlresolvers import reverse
5
5
6 from boards.models.base import Viewable
6 from boards.models.base import Viewable
7 from boards.utils import cached_result
7
8
8
9
9 __author__ = 'neko259'
10 __author__ = 'neko259'
@@ -70,5 +71,6 b' class Tag(models.Model, Viewable):'
70 'tag': self,
71 'tag': self,
71 })
72 })
72
73
74 @cached_result
73 def get_post_count(self):
75 def get_post_count(self):
74 return self.get_threads().aggregate(num_posts=Count('post'))['num_posts']
76 return self.get_threads().aggregate(num_posts=Count('post'))['num_posts']
General Comments 0
You need to be logged in to leave comments. Login now