Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def followers_for_story(story):
- topic_set = set(story['topic_list'])
- author_key = story['author_key']
- # Group the author's followers by user_key
- followers = sorted(self.socialgraph.follower_set(author_key))
- followers = groupby(followers,lambda x: x[0])
- # Iterate over each follower
- for follower_key, grouper in followers:
- # Create a topic set for the follower
- follow_topic_set = set(topic for (_, topic) in grouper)
- # If any followed topic is in the story's topic_set,
- # yield the follower_key
- if any((topic in topic_set) for topic in follow_topic_set):
- yield follower_key
Add Comment
Please, Sign In to add comment