Commit 49a53c4c by Jonathan Piacenti

Fixed subscription select by date.

parent 1d1800a5
...@@ -167,12 +167,8 @@ get "#{APIPREFIX}/users/:user_id/social_stats" do |user_id| ...@@ -167,12 +167,8 @@ get "#{APIPREFIX}/users/:user_id/social_stats" do |user_id|
# with the array of objectId's for threads, get a count of number of other users who have a subscription on it # with the array of objectId's for threads, get a count of number of other users who have a subscription on it
user_stats.keys.each do |user_id| user_stats.keys.each do |user_id|
if end_date then
user_stats[user_id]["num_thread_followers"] = Subscription.where(:subscriber_id.ne => user_id, :source_id.in => thread_ids[user_id], :created_at.lte => (end_date)).count()
else
user_stats[user_id]["num_thread_followers"] = Subscription.where(:subscriber_id.ne => user_id, :source_id.in => thread_ids[user_id]).count() user_stats[user_id]["num_thread_followers"] = Subscription.where(:subscriber_id.ne => user_id, :source_id.in => thread_ids[user_id]).count()
end end
end
# Get the number of threads read by each user. # Get the number of threads read by each user.
users = User.only([:_id, :read_states]).where("read_states.course_id" => course_id) users = User.only([:_id, :read_states]).where("read_states.course_id" => course_id)
......
...@@ -614,7 +614,7 @@ describe "app" do ...@@ -614,7 +614,7 @@ describe "app" do
make_request('*', DFLT_COURSE_ID, DateTime.new(2015, 02, 01)).should == {} make_request('*', DFLT_COURSE_ID, DateTime.new(2015, 02, 01)).should == {}
check_social_stats(make_request('*', DFLT_COURSE_ID, DateTime.new(2015, 03, 01)), { check_social_stats(make_request('*', DFLT_COURSE_ID, DateTime.new(2015, 03, 01)), {
@user1.id => make_social_stats(1,0,1,3,0,3,5,0,0), @user1.id => make_social_stats(1,0,1,3,0,3,5,1,0),
@user2.id => make_social_stats(0,1,0,0,0,1,0,0,0), @user2.id => make_social_stats(0,1,0,0,0,1,0,0,0),
}) })
......
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