def __init__(self, user_id, **kwargs): ''' User id (the user for which we want to read/write notifications) ''' AggregatedFeed.__init__(self, user_id, **kwargs) # location to which we denormalize the count self.format_dict = dict(user_id=user_id) self.count_key = self.count_format % self.format_dict # set the pubsub key if we're using it self.pubsub_key = user_id self.lock_key = self.lock_format % self.format_dict from feedly.storage.redis.connection import get_redis_connection self.redis = get_redis_connection()
def __init__(self, user_id, **kwargs): ''' User id (the user for which we want to read/write notifications) ''' AggregatedFeed.__init__(self, user_id, **kwargs) # location to which we denormalize the count self.format_dict = dict(user_id=user_id) self.count_key = self.count_format % self.format_dict # set the pubsub key if we're using it self.pubsub_key = user_id self.lock_key = self.lock_format % self.format_dict from feedly.storage.redis.connection import get_redis_connection self.redis = get_redis_connection()
def add_many(self, activities): ''' Similar to the AggregatedActivity.add_many The only difference is that it denormalizes a count of unseen activities ''' with self.redis.lock(self.lock_key, timeout=2): current_activities = AggregatedFeed.add_many(self, activities) # denormalize the count self.denormalize_count(current_activities) # return the current state of the notification feed return current_activities
def add_many(self, activities, **kwargs): ''' Similar to the AggregatedActivity.add_many The only difference is that it denormalizes a count of unseen activities ''' with self.redis.lock(self.lock_key, timeout=2): current_activities = AggregatedFeed.add_many(self, activities, **kwargs) # denormalize the count self.denormalize_count() # return the current state of the notification feed return current_activities