Mercurial > public > sg101
diff gpp/forums/management/commands/update_forum_stats.py @ 395:e10fa0d8e7ad
Fixing #192; cache some forum stats and have them be computed outside of the request/response cycle. Update the template tag to just read the cache.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 25 Mar 2011 00:27:10 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/forums/management/commands/update_forum_stats.py Fri Mar 25 00:27:10 2011 +0000 @@ -0,0 +1,17 @@ +""" +update_forum_stats.py - A management command to calculate and update the +cache with the forum statistics. These are done out of the request / +response cycle because doing a count on the Post table is expensive +under MySQL and InnoDb. + +""" +from django.core.management.base import NoArgsCommand, CommandError + +from forums.stats import update_stats + + +class Command(NoArgsCommand): + help = "Calculates and updates the cache with forums statistics" + + def handle_noargs(self, **opts): + update_stats()