diff --git a/ruby/spec/jam_ruby/models/active_music_session_spec.rb b/ruby/spec/jam_ruby/models/active_music_session_spec.rb index cf3a8b9f5..effc53291 100644 --- a/ruby/spec/jam_ruby/models/active_music_session_spec.rb +++ b/ruby/spec/jam_ruby/models/active_music_session_spec.rb @@ -364,14 +364,14 @@ describe ActiveMusicSession do music_sessions[1].tag.should_not be_nil music_sessions[1].latency.should_not be_nil - users = ActiveMusicSession.ams_users() + users = ActiveMusicSession.ams_users().take(100) users.should_not be_nil users.length.should == 2 if users[0].music_session_id == earlier_session.id - users[0].user_id.should == creator.id + users[0].id.should == creator.id users[0].latency.should == 15 # (5 + 20 + 5) / 2 users[1].music_session_id == later_session.id - users[1].user_id.should == creator2.id + users[1].id.should == creator2.id users[1].latency.should == 22 # (5 + 30 + 10) / 2 else users[0].music_session_id.should == later_session.id diff --git a/web/app/controllers/api_music_sessions_controller.rb b/web/app/controllers/api_music_sessions_controller.rb index 1a714b98c..1051997d6 100644 --- a/web/app/controllers/api_music_sessions_controller.rb +++ b/web/app/controllers/api_music_sessions_controller.rb @@ -70,15 +70,20 @@ class ApiMusicSessionsController < ApiController ActiveRecord::Base.transaction do ActiveMusicSession.ams_init(current_user, client_id: params[:client_id]) + # note that these queries must be actualized before the end of the transaction + # else the temporary tables created by ams_init will be gone. it would be better + # to have the caller wrap the whole thing in a transaction and then remove the + # .all calls here. + @music_sessions = ActiveMusicSession.ams_index(current_user, client_id: params[:client_id], genre: params[:genre], lang: params[:lang], keyword: params[:keyword], offset: params[:offset], - limit: params[:limit]) + limit: params[:limit]).all - # todo do something with saved music list ams_users_tmp? + @music_session_users = ActiveMusicSession.ams_users().all end end