##// END OF EJS Templates
Get PPD for the last week
neko259 -
r408:f80d4306 default
parent child Browse files
Show More
@@ -12,9 +12,10 b' from django.utils import timezone'
12 12 from markupfield.fields import MarkupField
13 13
14 14 from neboard import settings
15 from boards import settings as boards_settings
16 15 from boards import thumbs
17 16
17 POSTS_PER_DAY_RANGE = range(7)
18
18 19 BAN_REASON_AUTO = 'Auto'
19 20
20 21 IMAGE_THUMB_SIZE = (200, 150)
@@ -157,12 +158,19 b' class PostManager(models.Manager):'
157 158 """Get count of posts for the current day"""
158 159
159 160 today = datetime.now().date()
160 tomorrow = today + timedelta(1)
161 today_start = datetime.combine(today, dtime())
162 today_end = datetime.combine(tomorrow, dtime())
163 161
164 return self.filter(pub_time__lte=today_end, pub_time__gte=today_start)\
165 .count()
162 posts_per_days = []
163 for i in POSTS_PER_DAY_RANGE:
164 day_end = today + timedelta(i)
165 day_start = today + timedelta(i - 1)
166 day_time_start = datetime.combine(day_start, dtime())
167 day_time_end = datetime.combine(day_end, dtime())
168
169 posts_per_days.append(float(self.filter(pub_time__lte=day_time_end,
170 pub_time__gte=day_time_start).count()))
171
172 return sum(posts_per_day for posts_per_day in posts_per_days) / \
173 len(posts_per_days)
166 174
167 175
168 176 class Post(models.Model):
General Comments 0
You need to be logged in to leave comments. Login now