From 9b5d9bdea9658eeb3886e1d6f18bfedfeb9587a6 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Wed, 11 Jul 2012 10:52:50 -0700 Subject: [PATCH] Fixing bug when a story changes its guid (like on a tumblr rename), but it still thinks it has comments. Forcing each story to recount its comments if comments are claimed, just in case. --- apps/social/models.py | 6 ++---- media/js/newsblur/models/stories.js | 16 ++-------------- settings.py | 1 + 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/apps/social/models.py b/apps/social/models.py index 1cc7544e9..5666f9a8e 100644 --- a/apps/social/models.py +++ b/apps/social/models.py @@ -1182,8 +1182,7 @@ class MSharedStory(mongo.Document): story['public_comments'] = [] if check_all or story['comment_count']: comment_key = "C:%s:%s" % (story['story_feed_id'], story['guid_hash']) - if check_all: - story['comment_count'] = r.scard(comment_key) + story['comment_count'] = r.scard(comment_key) friends_with_comments = [int(f) for f in r.sinter(comment_key, friend_key)] sharer_user_ids = [int(f) for f in r.smembers(comment_key)] shared_stories = [] @@ -1213,8 +1212,7 @@ class MSharedStory(mongo.Document): if check_all or story['share_count']: share_key = "S:%s:%s" % (story['story_feed_id'], story['guid_hash']) - if check_all: - story['share_count'] = r.scard(share_key) + story['share_count'] = r.scard(share_key) friends_with_shares = [int(f) for f in r.sinter(share_key, friend_key)] nonfriend_user_ids = [int(f) for f in r.sdiff(share_key, friend_key)] profile_user_ids.update(nonfriend_user_ids) diff --git a/media/js/newsblur/models/stories.js b/media/js/newsblur/models/stories.js index 163fe9b5d..f9fd0a80e 100644 --- a/media/js/newsblur/models/stories.js +++ b/media/js/newsblur/models/stories.js @@ -8,20 +8,8 @@ NEWSBLUR.Models.Story = Backbone.Model.extend({ }, populate_comments: function(story, collection, changes) { - var friend_comments = this.get('friend_comments'); - var public_comments = this.get('public_comments'); - - if (!this.get('comment_count')) { - delete this.friend_comments; - delete this.public_comments; - } else { - if (friend_comments && friend_comments.length) { - this.friend_comments = new NEWSBLUR.Collections.Comments(friend_comments); - } - if (public_comments && public_comments.length) { - this.public_comments = new NEWSBLUR.Collections.Comments(public_comments); - } - } + this.friend_comments = new NEWSBLUR.Collections.Comments(this.get('friend_comments')); + this.public_comments = new NEWSBLUR.Collections.Comments(this.get('public_comments')); }, score: function() { diff --git a/settings.py b/settings.py index 0e66fc10a..2a7eff93f 100644 --- a/settings.py +++ b/settings.py @@ -389,6 +389,7 @@ MONGODB = connect(MONGO_DB.pop('name'), **MONGO_DB) # ========= REDIS_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=0) +REDIS_ANALYTICS_POOL = redis.ConnectionPool(host=REDIS['host'], port=6379, db=1) JAMMIT = jammit.JammitAssets(NEWSBLUR_DIR)