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.

This commit is contained in:
Samuel Clay 2012-07-11 10:52:50 -07:00
parent 01c2ae46f1
commit 9b5d9bdea9
3 changed files with 5 additions and 18 deletions

View file

@ -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)

View file

@ -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() {

View file

@ -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)