Ejemplo n.º 1
0
 def handle(self, *args, **options):
     for user in User.objects.all():
         post_ids = user.redis.feed_source[:]
         for post_id in post_ids:
             comment_details = CommentDetails.from_id(post_id)
             if not visible_in_feed({'comment': comment_details, 'type': 'post'}):
                 user.redis.feed_source.remove(post_id)
Ejemplo n.º 2
0
def publish_promoted_comment(comment_sticker, promoter):
    if comment_sticker.cost < knobs.FEED_PROMOTION_STICKER_COST_THRESHOLD:
        return

    from canvas.models import UserRedis

    comment = comment_sticker.comment

    if not visible_in_feed({'comment': comment.details(), 'type': 'promotion'}):
        return

    # Bump unseen counts for users who wouldn't already have this in their feed.
    for user_id in promoter.redis.followers.smembers():
        user_redis = UserRedis(user_id)

        following_ids = user_redis.following.smembers()

        if str(comment.author_id) in following_ids or str(comment.author_id) == str(user_id):
            # User already follows this author, or this author is the user himself.
            continue

        first_ts = users_promoted_comment_at(following_ids, comment)

        try:
            if float(first_ts) <= float(user_redis.user_kv.hget('feed_last_viewed')):
                # User viewed the feed after this was promoted.
                continue
        except TypeError:
            continue

        user_redis.user_kv.hincrby('feed_unseen', 1)

    updates_channel(promoter).publish({'comment': comment.id, 'type': 'promotion'})
Ejemplo n.º 3
0
def publish_new_comment(new_comment):
    from canvas.models import UserRedis

    if not visible_in_feed({'comment': new_comment.details(), 'type': 'post'}):
        return

    author = new_comment.author

    # Bump unseen counts.
    for user_id in author.redis.followers.smembers():
        user_redis = UserRedis(user_id)
        user_redis.user_kv.hincrby('feed_unseen', 1)

    updates_channel(author).publish({'comment': new_comment.id, 'type': 'post'})
Ejemplo n.º 4
0
def publish_new_comment(new_comment):
    from canvas.models import UserRedis

    if not visible_in_feed({'comment': new_comment.details(), 'type': 'post'}):
        return

    author = new_comment.author

    # Bump unseen counts.
    for user_id in author.redis.followers.smembers():
        user_redis = UserRedis(user_id)
        user_redis.user_kv.hincrby('feed_unseen', 1)

    updates_channel(author).publish({
        'comment': new_comment.id,
        'type': 'post'
    })
Ejemplo n.º 5
0
def publish_promoted_comment(comment_sticker, promoter):
    if comment_sticker.cost < knobs.FEED_PROMOTION_STICKER_COST_THRESHOLD:
        return

    from canvas.models import UserRedis

    comment = comment_sticker.comment

    if not visible_in_feed({
            'comment': comment.details(),
            'type': 'promotion'
    }):
        return

    # Bump unseen counts for users who wouldn't already have this in their feed.
    for user_id in promoter.redis.followers.smembers():
        user_redis = UserRedis(user_id)

        following_ids = user_redis.following.smembers()

        if str(comment.author_id) in following_ids or str(
                comment.author_id) == str(user_id):
            # User already follows this author, or this author is the user himself.
            continue

        first_ts = users_promoted_comment_at(following_ids, comment)

        try:
            if float(first_ts) <= float(
                    user_redis.user_kv.hget('feed_last_viewed')):
                # User viewed the feed after this was promoted.
                continue
        except TypeError:
            continue

        user_redis.user_kv.hincrby('feed_unseen', 1)

    updates_channel(promoter).publish({
        'comment': comment.id,
        'type': 'promotion'
    })