diff gpp/forums/stats.py @ 520:e94570675664

Created stats for users (number of users and list of newest users). Better separated the forums, who's online, and user stats. Use a Celery task to execute the new user stats processing. This addresses #194 and #238.
author Brian Neal <bgneal@gmail.com>
date Sat, 17 Dec 2011 23:19:15 +0000
parents e10fa0d8e7ad
children
line wrap: on
line diff
--- a/gpp/forums/stats.py	Sat Dec 17 19:29:24 2011 +0000
+++ b/gpp/forums/stats.py	Sat Dec 17 23:19:15 2011 +0000
@@ -3,31 +3,22 @@
 
 """
 from django.core.cache import cache
-from django.contrib.auth.models import User
 
 from forums.models import Post
 
 
-CACHE_KEY = 'forums-stats'
+CACHE_KEY = 'forums-stats-2'
 CACHE_TIMEOUT = 4 * 60 * 60         # seconds
 
 
 def calc_stats():
     """
     This function is responsible for computing the forum statistics.
-    A tuple is returned: (forums post count, active user count, latest username)
+    The forums post count is returned.
 
     """
     post_count = Post.objects.all().count()
-    user_count = User.objects.all().count()
-
-    if user_count > 0:
-        latest_user = User.objects.filter(is_active=True).values_list(
-                'username', flat=True).order_by('-date_joined')[0]
-    else:
-        latest_user = None
-
-    return post_count, user_count, latest_user
+    return post_count
 
 
 def update_stats():