No future dating mark read dates due to stories being future dated.

This commit is contained in:
Samuel Clay 2020-07-09 17:56:13 -04:00
parent d66537bd0f
commit 5c18498d99
2 changed files with 6 additions and 2 deletions

View file

@ -624,7 +624,9 @@ class UserSubscription(models.Model):
if cutoff_date:
cutoff_date = cutoff_date + datetime.timedelta(seconds=1)
else:
latest_story = MStory.objects(story_feed_id=self.feed.pk)\
now = datetime.datetime.now()
latest_story = MStory.objects(story_feed_id=self.feed.pk,
story_date__lte=now)\
.order_by('-story_date').only('story_date').limit(1)
if latest_story and len(latest_story) >= 1:
cutoff_date = (latest_story[0]['story_date']

View file

@ -1255,8 +1255,10 @@ class MSocialSubscription(mongo.Document):
cutoff_date = cutoff_date + datetime.timedelta(seconds=1)
else:
# Use the latest story to get last read time.
now = datetime.datetime.now()
latest_shared_story = MSharedStory.objects(user_id=self.subscription_user_id,
shared_date__gte=user_profile.unread_cutoff
shared_date__gte=user_profile.unread_cutoff,
story_date__lte=now
).order_by('-shared_date').only('shared_date').first()
if latest_shared_story:
cutoff_date = latest_shared_story['shared_date'] + datetime.timedelta(seconds=1)