Commit 3d902ee8 by Toby Lawrence Committed by GitHub

Merge pull request #202 from edx/perf/tracing-and-consistency

Add more tracing + code cleanup.
parents 1f4b77a9 01bd17bc
get "#{APIPREFIX}/threads" do # retrieve threads by course get "#{APIPREFIX}/threads" do # retrieve threads by course
threads = CommentThread.where({"course_id" => params["course_id"]})
threads = Content.where({"_type" => "CommentThread", "course_id" => params["course_id"]})
if params[:commentable_ids] if params[:commentable_ids]
threads = threads.in({"commentable_id" => params[:commentable_ids].split(",")}) threads = threads.in({"commentable_id" => params[:commentable_ids].split(",")})
end end
......
require 'new_relic/agent/method_tracer'
require_relative 'content' require_relative 'content'
require_relative 'constants' require_relative 'constants'
...@@ -164,4 +165,7 @@ class Comment < Content ...@@ -164,4 +165,7 @@ class Comment < Content
self.sk = (self.parent_ids.dup << self.id).join("-") self.sk = (self.parent_ids.dup << self.id).join("-")
end end
end end
include ::NewRelic::Agent::MethodTracer
add_method_tracer :to_hash
end end
...@@ -133,7 +133,6 @@ class CommentThread < Content ...@@ -133,7 +133,6 @@ class CommentThread < Content
"group_id" => group_id, "group_id" => group_id,
"pinned" => pinned?, "pinned" => pinned?,
"comments_count" => comment_count) "comments_count" => comment_count)
end end
def comment_thread_id def comment_thread_id
...@@ -162,4 +161,7 @@ class CommentThread < Content ...@@ -162,4 +161,7 @@ class CommentThread < Content
def destroy_subscriptions def destroy_subscriptions
subscriptions.delete_all subscriptions.delete_all
end end
include ::NewRelic::Agent::MethodTracer
add_method_tracer :to_hash
end end
...@@ -31,7 +31,7 @@ module ThreadUtils ...@@ -31,7 +31,7 @@ module ThreadUtils
unread_comment_count = Comment.collection.find( unread_comment_count = Comment.collection.find(
:comment_thread_id => t._id, :comment_thread_id => t._id,
:author_id => {"$ne" => user.id}, :author_id => {"$ne" => user.id},
:updated_at => {"$gte" => read_dates[thread_key]} :updated_at => {"$gte" => read_dates[thread_key]},
).count ).count
read_states[thread_key] = [is_read, unread_comment_count] read_states[thread_key] = [is_read, unread_comment_count]
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment