266 lines
7.5 KiB
Ruby
266 lines
7.5 KiB
Ruby
object @search
|
|
|
|
if @search.is_a?(BaseSearch)
|
|
|
|
node :page_count do |foo|
|
|
@search.page_count
|
|
end
|
|
|
|
node :my_audio_latency do |user|
|
|
current_user.last_jam_audio_latency.round if current_user.last_jam_audio_latency
|
|
end
|
|
|
|
node :filter_json do |foo|
|
|
@search.to_json
|
|
end
|
|
|
|
if @search.is_a? MusicianSearch
|
|
# node :description do |foo|
|
|
# @search.description
|
|
# end
|
|
|
|
# node :is_blank_filter do |foo|
|
|
# @search.is_blank?
|
|
# end
|
|
|
|
child(:results => :musicians) {
|
|
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :online, :musician, :photo_url, :biography, :regionname, :score, :full_score
|
|
|
|
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|
|
|
musician.pending_friend_request?(current_user)
|
|
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 :friend_count do |musician| @search.friend_count(musician) end
|
|
node :follow_count do |musician| @search.follow_count(musician) end
|
|
node :recording_count do |musician| @search.record_count(musician) end
|
|
node :session_count do |musician| @search.session_count(musician) end
|
|
|
|
node :audio_latency do |musician|
|
|
last_jam_audio_latency(musician)
|
|
end
|
|
|
|
node :latency_data do |musician|
|
|
|
|
if latency = @latency_data.detect{|l_data| l_data[:user_id] == musician.id }
|
|
{
|
|
audio_latency: latency[:audio_latency],
|
|
ars_internet_latency: latency[:ars_internet_latency],
|
|
ars_total_latency: latency[:ars_total_latency]
|
|
}
|
|
end if @latency_data
|
|
end
|
|
|
|
node :last_active_timestamp do |musician|
|
|
if musician.updated_at || musician.last_jam_updated_at
|
|
[musician.updated_at, musician.last_jam_updated_at].compact.max.to_i
|
|
end
|
|
end
|
|
|
|
child :genres => :genres do
|
|
attributes :genre_id, :description
|
|
end
|
|
}
|
|
|
|
elsif @search.is_a?(BandSearch)
|
|
|
|
# node :is_blank_filter do |foo|
|
|
# @search.is_blank?(params[:subtype])
|
|
# end
|
|
|
|
# node :description do |foo|
|
|
# @search.description(params[:subtype])
|
|
# end
|
|
|
|
# child(:results => :bands) {
|
|
# attributes :id, :name, :city, :state, :country, :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
|
|
|
|
else
|
|
|
|
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 :page_count do |foo|
|
|
# @search.page_count
|
|
# end
|
|
|
|
# node :my_audio_latency do |user|
|
|
# current_user.last_jam_audio_latency.round if current_user.last_jam_audio_latency
|
|
# end
|
|
|
|
# node :is_blank_filter do |foo|
|
|
# @search.is_blank?
|
|
# end
|
|
|
|
# node :filter_json do |foo|
|
|
# @search.to_json
|
|
# end
|
|
|
|
# child(:results => :musicians) {
|
|
# attributes :id, :first_name, :last_name, :name, :city, :state, :country, :online, :musician, :photo_url, :biography, :regionname, :score, :full_score
|
|
|
|
# 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|
|
|
# musician.pending_friend_request?(current_user)
|
|
# 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
|
|
|
|
# node :audio_latency do |musician|
|
|
# last_jam_audio_latency(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, :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 |fan|
|
|
# fan.pending_friend_request?(current_user)
|
|
# end
|
|
# }
|
|
# end
|
|
|
|
end
|