39 lines
1.1 KiB
Ruby
39 lines
1.1 KiB
Ruby
collection @bands
|
|
|
|
# do not retrieve all child collections when showing a list of bands
|
|
attributes :id, :name, :city, :state, :country, :location, :website, :biography, :photo_url, :logo_url, :liker_count, :follower_count, :recording_count, :session_count
|
|
|
|
node :musicians do |band|
|
|
unless band.users.nil? || band.users.size == 0
|
|
child :users => :musicians do
|
|
attributes :id, :first_name, :last_name, :name, :photo_url, :biography
|
|
|
|
# TODO: figure out how to omit empty arrays
|
|
node :instruments do |user|
|
|
unless user.instruments.nil? || user.instruments.size == 0
|
|
child :musician_instruments => :instruments do
|
|
attributes :instrument_id, :description, :proficiency_level, :priority
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
node :genres do |band|
|
|
unless band.genres.nil? || band.genres.size == 0
|
|
child :genres => :genres do
|
|
attributes :id, :description
|
|
end
|
|
end
|
|
end
|
|
|
|
node :biography do |band|
|
|
band.biography.nil? ? "" : band.biography
|
|
end
|
|
|
|
node :is_following do |band|
|
|
if current_user
|
|
current_user.following?(band)
|
|
end
|
|
end |