def _calculate_qa_comment_scores(link, cid_tree, comments):
 responder_ids = link.responder_ids
 parent_cids = []
 for comment in comments:
  if ((comment.author_id in responder_ids) and comment.parent_id):
   parent_cids.append(comment.parent_id)
 parent_comments = Comment._byID(parent_cids, return_dict=False)
 comments.extend(parent_comments)
 all_child_cids = []
 for comment in comments:
  child_cids = cid_tree.get(comment._id, None)
  if child_cids:
   all_child_cids.extend(child_cids)
 all_child_comments = Comment._byID(all_child_cids)
 comment_sorter = {}
 for comment in comments:
  child_cids = cid_tree.get(comment._id, ())
  child_comments = (all_child_comments[cid] for cid in child_cids)
  sort_value = comment._qa(child_comments, responder_ids)
  comment_sorter[comment._id36] = sort_value
 return comment_sorter

def _calculate_qa_comment_scores ( link , cid_tree , comments ) : responder_ids = link . responder_ids parent_cids = [ ] for comment in comments : if ( ( comment . author_id in responder_ids ) and comment . parent_id ) : parent_cids . append ( comment . parent_id ) parent_comments = Comment . _byID ( parent_cids , return_dict = False ) comments . extend ( parent_comments ) all_child_cids = [ ] for comment in comments : child_cids = cid_tree . get ( comment . _id , None ) if child_cids : all_child_cids . extend ( child_cids ) all_child_comments = Comment . _byID ( all_child_cids ) comment_sorter = { } for comment in comments : child_cids = cid_tree . get ( comment . _id , ( ) ) child_comments = ( all_child_comments [ cid ] for cid in child_cids ) sort_value = comment . _qa ( child_comments , responder_ids ) comment_sorter [ comment . _id36 ] = sort_value return comment_sorter
return a dict of comment_id36 -> qa score .