diff --git a/web/app/assets/javascripts/findMusician.js b/web/app/assets/javascripts/findMusician.js index 807f964e5..db6f30ed0 100644 --- a/web/app/assets/javascripts/findMusician.js +++ b/web/app/assets/javascripts/findMusician.js @@ -74,27 +74,58 @@ } else { $noMusiciansFound.hide(); - musicians = musicianList; - renderMusicians(); + musicians = musicianList['musicians']; + if (!(typeof musicians === 'undefined')) { + renderMusicians(); + } } } /** - * Render a list of musicians - */ + * Render a list of musicians + */ function renderMusicians() { var ii, len; var mTemplate = $('#template-find-musician-row').html(); + var fTemplate = $('#template-musician-follow-info').html(); var mVals, mm, renderings=''; - var instrument_html; + var instr_logos, instr; + var follows, followVals, aFollow; for (ii=0, len=musicians.length; ii < len; ii++) { mm = musicians[ii]; + instr_logos = ''; + for (var jj=0, ilen=mm['instruments'].length; jj '; + } + follows = ''; + followVals = {}; + for (var jj=0, ilen=mm['followings'].length; jj :instruments do attributes :instrument_id, :description, :proficiency_level, :priority end + + child :user_followings => :followings do |uf| + node :user_id do |uu| uu.following.id end + node :photo_url do |uu| uu.following.photo_url end + node :name do |uu| uu.following.name end + end + + node :follow_count do |musician| musician.follow_count end + node :friend_count do |musician| musician.friend_count end } end diff --git a/web/app/views/clients/_musician_filter.html.erb b/web/app/views/clients/_musician_filter.html.erb index fd1ddee37..002ced989 100644 --- a/web/app/views/clients/_musician_filter.html.erb +++ b/web/app/views/clients/_musician_filter.html.erb @@ -1,7 +1,7 @@
Filter Musician List:
- <%= select_tag(:musician_order_by, options_for_select(Search::ORDERINGS), {:class => 'musician-order-by'} ) %> + <%= select_tag(:musician_order_by, options_for_select(Search::M_ORDERINGS), {:class => 'musician-order-by'} ) %>
<%= select_tag(:instrument, diff --git a/web/app/views/clients/_musician_filter_result.html.erb b/web/app/views/clients/_musician_filter_result.html.erb deleted file mode 100644 index 89597fec1..000000000 --- a/web/app/views/clients/_musician_filter_result.html.erb +++ /dev/null @@ -1,50 +0,0 @@ -
- - -
- - -
David Wilson
- San Francisco, CA -

- -
-
-
-

- - - 122    4    17    64


- -
-

- Nulla facilisi. In vel sem. Morbi id urna in diam dignissim feugiat. Proin molestie tortor eu velit. Aliquam erat volutpat. Nullam ultrices, diam tempus vulputate egestas, eros pede varius leo, sed imperdiet lectus est ornare odio.
-
- PROFILELIKEFRIENDFOLLOW
-
-
- FOLLOWING: - - - - - - - - - - - - - - - - -
Fox Force Five
Tammany Hall
Bethany Grey
-
- - - -
-
- diff --git a/web/app/views/clients/_musicians.html.erb b/web/app/views/clients/_musicians.html.erb index 6bd5b4bed..9818fbb56 100644 --- a/web/app/views/clients/_musicians.html.erb +++ b/web/app/views/clients/_musicians.html.erb @@ -42,34 +42,32 @@ {instruments}


- 122    4    17    64

+ {follow_count}    4    17    64


- Nulla facilisi. In vel sem. Morbi id urna in diam dignissim feugiat. Proin molestie tortor eu velit. Aliquam erat volutpat. Nullam ultrices, diam tempus vulputate egestas, eros pede varius leo, sed imperdiet lectus est ornare odio.
+ {biography}

- PROFILELIKEFRIENDFOLLOW
+ PROFILELIKEFRIENDFOLLOW

FOLLOWING: - - - - - - - - - - - - - - - + {musician_follow_template}
Fox Force Five
Tammany Hall
Bethany Grey

+ + + diff --git a/web/lib/tasks/sample_data.rake b/web/lib/tasks/sample_data.rake index 5eca16faf..0d10b91b7 100644 --- a/web/lib/tasks/sample_data.rake +++ b/web/lib/tasks/sample_data.rake @@ -2,10 +2,14 @@ namespace :db do desc "Fill database with sample data" task populate: :environment do make_users - make_microposts + # make_microposts make_relationships end + task populate_followings: :environment do + make_followings + end + desc "Fill database with music session sample data" task populate_music_sessions: :environment do make_users(10) if 14 > User.count @@ -102,6 +106,16 @@ def make_relationships user = users.first followed_users = users[2..50] followers = users[3..40] - followed_users.each { |followed| user.follow!(followed) } + followed_users.each { |followed| user.followings << followed } followers.each { |follower| follower.follow!(user) } +end + +def make_followings + users = User.all + users[6..-1].each do |uu| + users[0..5].shuffle.each do |uuu| + uu.followings << uuu + uuu.followings << uu + end + end end \ No newline at end of file diff --git a/web/spec/requests/musician_search_api_spec.rb b/web/spec/requests/musician_search_api_spec.rb index f79db9596..36f11122c 100644 --- a/web/spec/requests/musician_search_api_spec.rb +++ b/web/spec/requests/musician_search_api_spec.rb @@ -45,5 +45,46 @@ describe "Musician Search API", :type => :api do instruments.detect { |ii| ii['instrument_id'] == 'tuba' }.should_not == nil instruments.detect { |ii| ii['instrument_id'] == 'electric guitar' }.should_not == nil end + + it "following search" do + params = { + first_name: "Example", + last_name: "User", + email: "user1@example.com", + password: "foobar", + password_confirmation: "foobar", + musician: true, + email_confirmed: true, + city: "Apex", + state: "NC", + country: "US" + } + @users = [] + @users << @user1 = FactoryGirl.create(:user, params) + params[:email] = "user2@example.com" + @users << @user2 = FactoryGirl.create(:user, params) + params[:email] = "user3@example.com" + @users << @user3 = FactoryGirl.create(:user, params) + params[:email] = "user4@example.com" + @users << @user4 = FactoryGirl.create(:user, params) + @user4.followers.concat([@user2, @user3, @user4]) + @user3.followers.concat([@user3, @user4]) + @user2.followers.concat([@user4]) + @user4.followers.count.should == 3 + + Friendship.save(@user1.id, @user2.id) + + get_query + last_response.status.should == 200 + response = JSON.parse(last_response.body) + + musician = response["musicians"][0] + musician["id"].should == @user4.id + followings= musician['followings'] + followings.length.should == 3 + + friend = response['musicians'].detect { |mm| mm['id'] == @user1.id } + friend['friend_count'].should == 1 + end end end