def get_full_topics(topics): users = get_cache_list(Member, get_user_id_list(topics), 'member:') nodes = get_cache_list(Node, (t.node_id for t in topics), 'node:') for topic in topics: if topic.user_id in users and topic.node_id in nodes: topic.user = users[topic.user_id] if topic.last_reply_by: topic.replyer = users[topic.last_reply_by] else: topic.replyer = None topic.node = nodes[topic.node_id] yield topic
def get_full_notifications(messages): users = get_cache_list(Member, (m.sender for m in messages), 'member:') for msg in messages: if msg.sender in users: msg.who = users[msg.sender] yield msg
def get_full_replies(replies): users = get_cache_list(Member, (r.user_id for r in replies), 'member:') for reply in replies: if reply.user_id in users: reply.user = users[reply.user_id] yield reply