changeset 407:42a4e66972d5

Trying to fix #200; found a bug in the get_forum_unread_status() function. Added some db indexes.
author Brian Neal <bgneal@gmail.com>
date Fri, 01 Apr 2011 01:18:44 +0000
parents f469261d617b
children 7e0997b08b50
files gpp/forums/models.py gpp/forums/unread.py
diffstat 2 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/gpp/forums/models.py	Thu Mar 31 00:38:02 2011 +0000
+++ b/gpp/forums/models.py	Fri Apr 01 01:18:44 2011 +0000
@@ -190,7 +190,7 @@
     """
     forum = models.ForeignKey(Forum, related_name='topics')
     name = models.CharField(max_length=255)
-    creation_date = models.DateTimeField(auto_now_add=True)
+    creation_date = models.DateTimeField(db_index=True)
     user = models.ForeignKey(User)
     view_count = models.IntegerField(blank=True, default=0)
     sticky = models.BooleanField(blank=True, default=False)
@@ -371,7 +371,7 @@
     """
     user = models.ForeignKey(User)
     topic = models.ForeignKey(Topic)
-    last_visit = models.DateTimeField()
+    last_visit = models.DateTimeField(db_index=True)
 
     class Meta:
         unique_together = ('user', 'topic')
--- a/gpp/forums/unread.py	Thu Mar 31 00:38:02 2011 +0000
+++ b/gpp/forums/unread.py	Fri Apr 01 01:18:44 2011 +0000
@@ -101,15 +101,15 @@
                 if topic.id in tracked_dict:
                     if topic.update_date > tracked_dict[topic.id].last_visit:
                         forum.has_unread = True
-                        continue
+                        break
                 else:
                     forum.has_unread = True
-                    continue
-
-            # If we made it through the above loop without continuing, then
-            # we are all caught up.
-            forum.catchup(user, flv)
-            forum.has_unread = False
+                    break
+            else:
+                # If we made it through the above loop without breaking out,
+                # then we are all caught up.
+                forum.catchup(user, flv)
+                forum.has_unread = False
 
 #######################################################################