92 lines
2.4 KiB
Ruby
92 lines
2.4 KiB
Ruby
object @recording
|
|
|
|
attributes :id, :band, :created_at, :duration, :comment_count, :like_count, :play_count, :when_will_be_discarded?, :jam_track_id, :jam_track_initiator_id, :music_session_id, :music_session, :video
|
|
|
|
node :fan_access do |recording|
|
|
recording.non_active_music_session.fan_access
|
|
end
|
|
|
|
node :mix do |recording|
|
|
if recording.mix
|
|
{
|
|
id: recording.mix.id
|
|
}
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
|
|
node :timeline do |recording|
|
|
recording.timeline ? JSON.parse(recording.timeline) : {}
|
|
end
|
|
|
|
child(:jam_track => :jam_track) {
|
|
attributes :id
|
|
|
|
node :jmep do |jam_track|
|
|
jam_track.jmep_json ? JSON.parse(jam_track.jmep_json) : nil
|
|
end
|
|
}
|
|
|
|
child(:band => :band) {
|
|
attributes :id, :name, :location, :photo_url
|
|
}
|
|
|
|
child(:owner => :owner) {
|
|
attributes :id, :name, :location, :photo_url
|
|
}
|
|
|
|
child(:recorded_tracks => :recorded_tracks) {
|
|
node do |recorded_track|
|
|
partial("api_recordings/show_recorded_track", :object => recorded_track)
|
|
end
|
|
}
|
|
|
|
child(:recorded_backing_tracks => :recorded_backing_tracks) {
|
|
node do |recorded_backing_track|
|
|
partial("api_recordings/show_recorded_backing_track", :object => recorded_backing_track)
|
|
end
|
|
}
|
|
|
|
child(:recorded_jam_track_tracks => :recorded_jam_track_tracks) {
|
|
node do |recorded_jam_track_track|
|
|
{
|
|
id: recorded_jam_track_track.jam_track_track.id,
|
|
timeline: recorded_jam_track_track.timeline ? JSON.parse(recorded_jam_track_track.timeline) : []
|
|
}
|
|
end
|
|
}
|
|
|
|
child(:comments => :comments) {
|
|
attributes :comment, :created_at
|
|
|
|
child(:user => :creator) {
|
|
attributes :id, :first_name, :last_name, :photo_url
|
|
}
|
|
}
|
|
|
|
# returns the current_user's version of the recording, i.e., their associated claimed_recording if present
|
|
node :my do |recording|
|
|
claim = recording.claim_for_user(current_user) || recording.candidate_claimed_recording
|
|
if claim
|
|
{ name: claim.name, description: claim.description, genre: claim.genre.id, genre_name: claim.genre.description, id: claim.id }
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
|
|
child(:claimed_recordings => :claimed_recordings) {
|
|
|
|
attributes :id, :name, :description, :is_public, :genre_id, :has_mix?, :user_id
|
|
|
|
node :share_url do |claimed_recording|
|
|
unless claimed_recording.share_token.nil?
|
|
share_token_url(claimed_recording.share_token.token)
|
|
end
|
|
end
|
|
|
|
node :mix do |claimed_recording|
|
|
listen_mix_url(claimed_recording.recording) if claimed_recording.has_mix?
|
|
end
|
|
}
|