in models/comment.rb [78:108]
def to_hash(params={})
sort_by_parent_and_time = Proc.new do |x, y|
arr_cmp = x.parent_ids.map(&:to_s) <=> y.parent_ids.map(&:to_s)
if arr_cmp != 0
arr_cmp
else
x.created_at <=> y.created_at
end
end
if params[:recursive]
subtree_hash = subtree(sort: sort_by_parent_and_time)
self.class.hash_tree(subtree_hash).first
else
as_document
.slice(BODY, COURSE_ID, ENDORSED, ENDORSEMENT, ANONYMOUS, ANONYMOUS_TO_PEERS, CREATED_AT, UPDATED_AT, AT_POSITION_LIST)
.merge!("id" => _id,
"user_id" => author_id,
"username" => author_username,
"depth" => depth,
"closed" => comment_thread.nil? ? false : comment_thread.closed,
"thread_id" => comment_thread_id,
"parent_id" => parent_ids[-1],
"commentable_id" => comment_thread.nil? ? nil : comment_thread.commentable_id,
"votes" => votes.slice(COUNT, UP_COUNT, DOWN_COUNT, POINT),
"abuse_flaggers" => abuse_flaggers,
"type" => COMMENT,
"child_count" => get_cached_child_count)
end
end