130 lines
3.4 KiB
Ruby
130 lines
3.4 KiB
Ruby
object @search
|
|
|
|
node :search_type do |ss| ss.search_type end
|
|
|
|
if @search.session_invite_search?
|
|
child(:results => :suggestions) {
|
|
node :value do |uu| uu.name end
|
|
node :data do |uu| uu.id end
|
|
}
|
|
end
|
|
|
|
if @search.bands_text_search?
|
|
child(:results => :bands) {
|
|
attributes :id, :name, :location, :photo_url, :logo_url, :website
|
|
}
|
|
end
|
|
|
|
if @search.musicians_text_search?
|
|
child(:results => :musicians) {
|
|
attributes :id, :first_name, :last_name, :name, :location, :photo_url
|
|
|
|
node :is_friend do |musician|
|
|
musician.friends?(current_user)
|
|
end
|
|
|
|
node :pending_friend_request do |musician|
|
|
musician.pending_friend_request?(current_user)
|
|
end
|
|
|
|
child :musician_instruments => :instruments do
|
|
attributes :instrument_id, :description, :proficiency_level, :priority
|
|
end
|
|
}
|
|
end
|
|
|
|
if @search.musicians_filter_search?
|
|
|
|
node :city do |user|
|
|
current_user.try(:location)
|
|
end
|
|
|
|
node :page_count do |foo|
|
|
@search.page_count
|
|
end
|
|
|
|
child(:results => :musicians) {
|
|
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :email, :online, :musician, :photo_url, :biography
|
|
|
|
node :is_friend do |musician|
|
|
@search.is_friend?(musician)
|
|
end
|
|
|
|
node :is_following do |musician|
|
|
@search.is_follower?(musician)
|
|
end
|
|
|
|
node :pending_friend_request do |musician|
|
|
@search.pending_friend_request?(musician)
|
|
end
|
|
|
|
node :biography do |musician|
|
|
musician.biography.nil? ? "" : musician.biography
|
|
end
|
|
|
|
child :musician_instruments => :instruments do
|
|
attributes :instrument_id, :description, :proficiency_level, :priority
|
|
end
|
|
|
|
child :top_followings => :followings do |uf|
|
|
node :user_id do |uu| uu.id end
|
|
node :photo_url do |uu| uu.photo_url end
|
|
node :name do |uu| uu.name end
|
|
end
|
|
|
|
node :follow_count do |musician| @search.follow_count(musician) end
|
|
node :friend_count do |musician| @search.friend_count(musician) end
|
|
node :recording_count do |musician| @search.record_count(musician) end
|
|
node :session_count do |musician| @search.session_count(musician) end
|
|
}
|
|
end
|
|
|
|
if @search.bands_filter_search?
|
|
|
|
node :page_count do |foo|
|
|
@search.page_count
|
|
end
|
|
|
|
child(:results => :bands) {
|
|
attributes :id, :name, :city, :state, :country, :email, :photo_url, :biography, :logo_url, :website
|
|
|
|
node :is_following do |band|
|
|
@search.is_follower?(band)
|
|
end
|
|
|
|
node :biography do |band|
|
|
band.biography.nil? ? "" : band.biography
|
|
end
|
|
|
|
child :genres => :genres do
|
|
attributes :genre_id, :description
|
|
end
|
|
|
|
child :users => :players do |pl|
|
|
node :user_id do |uu| uu.id end
|
|
node :photo_url do |uu| uu.photo_url end
|
|
node :name do |uu| uu.name end
|
|
node :instruments do |uu| uu.instruments.map(&:id).join(',') end
|
|
end
|
|
|
|
node :follow_count do |band| @search.follow_count(band) end
|
|
node :recording_count do |band| @search.record_count(band) end
|
|
node :session_count do |band| @search.session_count(band) end
|
|
}
|
|
end
|
|
|
|
if @search.fans_text_search?
|
|
child(:results => :fans) {
|
|
attributes :id, :first_name, :last_name, :name, :location, :photo_url
|
|
|
|
node :is_friend do |fan|
|
|
fan.friends?(current_user)
|
|
end
|
|
|
|
node :pending_friend_request do |musician|
|
|
@search.pending_friend_request?(musician)
|
|
end
|
|
}
|
|
end
|
|
|