mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Adding has_comments boolean to shared stories for efficieny.
This commit is contained in:
parent
30454c6355
commit
0d34f9a402
2 changed files with 4 additions and 1 deletions
|
@ -6,6 +6,7 @@ class MSharedStory(mongo.Document):
|
|||
user_id = mongo.IntField()
|
||||
shared_date = mongo.DateTimeField()
|
||||
comments = mongo.StringField()
|
||||
has_comments = mongo.BooleanField(default=False)
|
||||
story_feed_id = mongo.IntField()
|
||||
story_date = mongo.DateTimeField()
|
||||
story_title = mongo.StringField(max_length=1024)
|
||||
|
|
|
@ -28,12 +28,14 @@ def mark_story_as_shared(request):
|
|||
story_db = dict([(k, v) for k, v in story[0]._data.items()
|
||||
if k is not None and v is not None])
|
||||
now = datetime.datetime.now()
|
||||
story_values = dict(user_id=request.user.pk, shared_date=now, comments=comments, **story_db)
|
||||
story_values = dict(user_id=request.user.pk, shared_date=now, comments=comments,
|
||||
has_comments=bool(comments), **story_db)
|
||||
MSharedStory.objects.create(**story_values)
|
||||
logging.user(request, "~FCSharing: ~SB~FM%s (~FB%s~FM)" % (story[0].story_title[:50], comments[:100]))
|
||||
else:
|
||||
shared_story = shared_story[0]
|
||||
shared_story.comments = comments
|
||||
shared_story.has_comments = bool(comments)
|
||||
shared_story.save()
|
||||
logging.user(request, "~FCUpdating shared story: ~SB~FM%s (~FB%s~FM)" % (story[0].story_title[:50], comments[:100]))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue