From 0230fd64ef3efeddd582df93bc72a0fc5da467bf Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Fri, 10 Sep 2010 08:38:50 -0700 Subject: [PATCH] While story_guids are not fully migrated, need to check for both guid and unicode ID. --- apps/reader/models.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/reader/models.py b/apps/reader/models.py index 08fb15d3e..66c6a0c8e 100644 --- a/apps/reader/models.py +++ b/apps/reader/models.py @@ -77,11 +77,22 @@ class UserSubscription(models.Model): self.mark_read_date = date_delta read_stories = MUserStory.objects(user_id=self.user.pk, - feed_id=self.feed.pk) - read_stories_ids = [rs.story.id for rs in read_stories] + feed_id=self.feed.pk, + read_date__gte=self.mark_read_date) + read_stories_ids = [] + for us in read_stories: + if hasattr(us.story, 'story_guid') and isinstance(us.story.story_guid, unicode): + read_stories_ids.append(us.story.story_guid) + elif hasattr(us.story, 'id') and isinstance(us.story.id, unicode): + read_stories_ids.append(us.story.id) # TODO: Remove me after migration from story.id->guid stories_db = MStory.objects(story_feed_id=self.feed.pk, story_date__gte=date_delta) - stories_db = [story for story in stories_db if story.id not in read_stories_ids] + unread_stories_db = [] + for story in stories_db: + if hasattr(us.story, 'story_guid') and story.story_guid not in read_stories_ids: + unread_stories_db.append(story) + elif isinstance(us.story.id, unicode) and story.id not in read_stories_ids: + unread_stories_db.append(story) stories = self.feed.format_stories(stories_db) classifier_feeds = MClassifierFeed.objects(user_id=self.user.pk, feed_id=self.feed.pk)