Commit 8f69e22c by Chris Dodge Committed by Jonathan Piacenti

add a get_num_followers endpoint

parent 49a53c4c
get "#{APIPREFIX}/threads" do # retrieve threads by course get "#{APIPREFIX}/threads" do # retrieve threads by course
threads = Content.where({"_type" => "CommentThread", "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(",")})
...@@ -105,3 +105,16 @@ get "#{APIPREFIX}/courses/*/stats" do |course_id| # retrieve stats by course ...@@ -105,3 +105,16 @@ get "#{APIPREFIX}/courses/*/stats" do |course_id| # retrieve stats by course
course_stats.to_json course_stats.to_json
end end
end end
get "#{APIPREFIX}/threads/:thread_id/num_followers" do |thread_id|
begin
exclude_user_id = 0
if params.has_key?("exclude_user_id")
exclude_user_id = Integer(params["exclude_user_id"])
end
thread_followers = {
"num_followers" => Subscription.where(:subscriber_id.ne => exclude_user_id, source_id: thread_id).count()
}
thread_followers.to_json
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