mirror of
https://github.com/Mistake35/Cedar-Django.git
synced 2026-07-18 00:21:14 +10:00
hmm
- Removed the comments inline thing because it was slow - Sorting by popularity is now limited by posts within 7 days. I am not sure how this will impact performance but hopefully it wont be as slow.
This commit is contained in:
@@ -681,12 +681,11 @@ class Community(models.Model):
|
||||
objects = PostManager()
|
||||
real = models.Manager()
|
||||
def popularity(self):
|
||||
if self.creator:
|
||||
# don't count posts from the community owner.
|
||||
popularity = Post.objects.filter(community=self).exclude(creator=self.creator).count()
|
||||
else:
|
||||
popularity = Post.objects.filter(community=self).count()
|
||||
return popularity
|
||||
# Get the date 7 days ago from today
|
||||
start_date = timezone.now() - timedelta(days=7)
|
||||
popularity = Post.objects.filter(community=self, created__gte=start_date)
|
||||
return popularity.count()
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
def icon(self):
|
||||
|
||||
Reference in New Issue
Block a user