daily pastebin goal
83%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def followers_for_story(story):
  2.         topic_set = set(story['topic_list'])
  3.         author_key = story['author_key']
  4.  
  5.     # Group the author's followers by user_key                                                                                                                                  
  6.         followers = sorted(self.socialgraph.follower_set(author_key))
  7.     followers = groupby(followers,lambda x: x[0])
  8.  
  9.     # Iterate over each follower                                                                                                                                                
  10.         for follower_key, grouper in followers:
  11.             # Create a topic set for the follower                                                                                                                                    
  12.             follow_topic_set = set(topic for (_, topic) in grouper)
  13.  
  14.             # If any followed topic is in the story's topic_set,                                                                                                                    
  15.             # yield the follower_key                                                                                                                                                
  16.             if any((topic in topic_set) for topic in follow_topic_set):
  17.         yield follower_key
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top