comparison gpp/forums/models.py @ 239:dcc929973bba

Fix the max users online statistic as per ticket #90.
author Brian Neal <bgneal@gmail.com>
date Sun, 12 Sep 2010 18:30:23 +0000
parents a46788862737
children d424b8bae71d
comparison
equal deleted inserted replaced
238:a3b47d0f4df1 239:dcc929973bba
359 super(TopicLastVisit, self).save(*args, **kwargs) 359 super(TopicLastVisit, self).save(*args, **kwargs)
360 360
361 def touch(self): 361 def touch(self):
362 self.last_visit = datetime.datetime.now() 362 self.last_visit = datetime.datetime.now()
363 363
364
365 class Statistic(models.Model):
366 """
367 This model keeps track of forum statistics. Currently, the only statistic
368 is the maximum number of users online. This stat is computed by a mgmt.
369 command that is run on a cron job to peek at the "users_online" dict
370 that is maintained in cache by the forums middleware.
371 """
372 max_users = models.IntegerField()
373 max_users_date = models.DateTimeField()
374
375 def __unicode__(self):
376 return u'%d users on %s' % (self.max_users,
377 self.max_users_date.strftime('%Y-%m-%d %H:%M:%S'))
378
379 def save(self, *args, **kwargs):
380 self.max_users_date = datetime.datetime.now()
381 super(Statistic, self).save(*args, **kwargs)