def myfeed(follower_id): if request.method == 'GET': feed_name = FEED_ID % (follower_id,) data = rconn.lrange(feed_name, 0, 10) print 'data', data enriched_results = map(enrich_item, data) return jsonify({'results': enriched_results}) item_id = generate_new_id() data = json.loads(request.data) print data publish_item.delay(follower_id, item_id, data) return jsonify({'msg': '%s successfully created' % item_id})
def remove_leader_from_follower_feed(follower_id, leader_id): """ Get all items in follower's feed and filter out leader's """ feed = FEED_ID % (follower_id,) feed_length = rconn.llen(feed) items = rconn.lrange(feed, 0, feed_length) removed_count = 0 for i, item_id in enumerate(items): item = db_session.query(Item).get(Item.id==item_id) if item.created_by == leader_id: rconn.lrem(item_id, i - removed_count, leader_id) removed_count += 1 print '%d items removed from feed %s' % (removed_count, feed)