# HG changeset patch # User Brian Neal # Date 1301620724 0 # Node ID 42a4e66972d5c8acfc84e2cc89c8ece5ddb9560f # Parent f469261d617bde16d369f074b6a6bad763482a8e Trying to fix #200; found a bug in the get_forum_unread_status() function. Added some db indexes. diff -r f469261d617b -r 42a4e66972d5 gpp/forums/models.py --- 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') diff -r f469261d617b -r 42a4e66972d5 gpp/forums/unread.py --- 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 #######################################################################