mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Remove highlights count when it reaches zero.
This commit is contained in:
parent
cb6fe9d801
commit
a29f1235a4
1 changed files with 7 additions and 2 deletions
|
@ -3094,8 +3094,13 @@ class MStarredStoryCounts(mongo.Document):
|
|||
highlighted_count = MStarredStory.objects(user_id=user_id,
|
||||
highlights__exists=True,
|
||||
__raw__={"$where": "this.highlights.length > 0"}).count()
|
||||
cls.objects(user_id=user_id,
|
||||
is_highlights=True, slug="highlights").update_one(set__count=highlighted_count, upsert=True)
|
||||
if highlighted_count > 0:
|
||||
cls.objects(user_id=user_id,
|
||||
is_highlights=True,
|
||||
slug="highlights"
|
||||
).update_one(set__count=highlighted_count, upsert=True)
|
||||
else:
|
||||
cls.objects(user_id=user_id, is_highlights=True, slug="highlights").delete()
|
||||
|
||||
return highlighted_count
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue