Mercurial > public > sg101
diff gpp/forums/models.py @ 164:f7a6b8fe4556
Implement #46, add a forums stat feature like phpBB.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 28 Dec 2009 16:52:42 +0000 |
parents | 48621ba5c385 |
children | cf9f9d4c4d54 |
line wrap: on
line diff
--- a/gpp/forums/models.py Tue Dec 22 03:56:26 2009 +0000 +++ b/gpp/forums/models.py Mon Dec 28 16:52:42 2009 +0000 @@ -337,3 +337,22 @@ def touch(self): self.last_visit = datetime.datetime.now() + + +class Statistic(models.Model): + """ + This model keeps track of forum statistics. Currently, the only statistic + is the maximum number of users online. This stat is computed by a mgmt. + command that is run on a cron job to peek at the "users_online" dict + that is maintained in cache by the forums middleware. + """ + max_users = models.IntegerField() + max_users_date = models.DateTimeField() + + def __unicode__(self): + return u'%d users on %s' % (self.max_users, + self.max_users_date.strftime('%Y-%m-%d %H:%M:%S')) + + def save(self, *args, **kwargs): + self.max_users_date = datetime.datetime.now() + super(Statistic, self).save(*args, **kwargs)