* adding sample data building to create a recording with a mix. VRFS-1135
This commit is contained in:
parent
da090bd1a9
commit
ac677ebdf1
|
|
@ -27,11 +27,11 @@ child(:recording => :recording) {
|
|||
attributes :id, :is_completed
|
||||
|
||||
node :mp3_url do |mix|
|
||||
mix[:url]
|
||||
mix[:mp3_url]
|
||||
end
|
||||
|
||||
node :ogg_url do |mix|
|
||||
mix[:url]
|
||||
mix[:ogg_url]
|
||||
end
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,11 +49,11 @@ glue :claimed_recording do
|
|||
attributes :id, :is_completed
|
||||
|
||||
node :mp3_url do |mix|
|
||||
mix[:url]
|
||||
mix[:mp3_url]
|
||||
end
|
||||
|
||||
node :ogg_url do |mix|
|
||||
mix[:url]
|
||||
mix[:ogg_url]
|
||||
end
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,11 +62,11 @@ node(:claimed_recording, :if => lambda { |music_session| music_session.users.exi
|
|||
attributes :id, :is_completed
|
||||
|
||||
node :mp3_url do |mix|
|
||||
mix[:url]
|
||||
mix[:mp3_url]
|
||||
end
|
||||
|
||||
node :ogg_url do |mix|
|
||||
mix[:url]
|
||||
mix[:ogg_url]
|
||||
end
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,47 @@ namespace :db do
|
|||
make_band_genres
|
||||
end
|
||||
|
||||
task populate_claimed_recording: :environment do
|
||||
# need 4 users.
|
||||
users = User.where(musician: true).limit(4)
|
||||
raise "need at least 4 musicians in the database to create a recording" if users.length < 4
|
||||
|
||||
user1 = users[0]
|
||||
user2 = users[1]
|
||||
user3 = users[2]
|
||||
user4 = users[3]
|
||||
|
||||
recording = Recording.new
|
||||
recording.name = 'sample data'
|
||||
recording.owner = user1
|
||||
|
||||
make_recorded_track(recording, user1, 'bass guitar', 'f86949abc213a3ccdc9d266a2ee56453', 2579467, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-adrian-bass.ogg')
|
||||
make_recorded_track(recording, user1, 'voice', '264cf4e0bf14d44109322a504d2e6d18', 2373055, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-adrian-vox.ogg')
|
||||
make_recorded_track(recording, user2, 'electric guitar', '9f322e1991b8c04b00dc9055d6be933c', 2297867, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-chris-guitar.ogg')
|
||||
make_recorded_track(recording, user2, 'voice', '3c7dcb7c4c35c0bb313fc15ee3e6bfd5', 2244968, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-chris-vox.ogg')
|
||||
make_recorded_track(recording, user3, 'voice', '10ca4c6ef5b98b3489ae8da1c7fa9cfb', 2254275, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-matt-lead-vox.ogg')
|
||||
make_recorded_track(recording, user4, 'drums', 'ea366f482fa969e1fd8530c13cb75716', 2386250, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-randy-drum1.ogg')
|
||||
make_recorded_track(recording, user4, 'drums', '4c693c6e99117719c6340eb68b0fe574', 2566463, 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/track-randy-drum2.ogg')
|
||||
|
||||
make_claimed_recording(recording, user1, 'Poison', 'Classic song that you all know -- user1')
|
||||
make_claimed_recording(recording, user2, 'Poison', 'Classic song that you all know -- user2')
|
||||
make_claimed_recording(recording, user3, 'Poison', 'Classic song that you all know -- user3')
|
||||
make_claimed_recording(recording, user4, 'Poison', 'Classic song that you all know -- user4')
|
||||
|
||||
mix = Mix.new
|
||||
mix.started_at = Time.now
|
||||
mix.completed_at = Time.now
|
||||
mix[:ogg_url] = 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/master-out.ogg'
|
||||
mix.ogg_md5 = 'f1fee708264602e1705638e53f0ea667'
|
||||
mix.ogg_length = 2500633
|
||||
mix[:mp3_url] = 'https://jamjam:blueberryjam@int.jamkazam.com/stuff/lc_rocks_poison/master-out.mp3'
|
||||
mix.mp3_md5 = 'df05abad96e5cb8439f7cd6e31b5c503'
|
||||
mix.mp3_length = 3666137
|
||||
mix.completed = true
|
||||
recording.mixes << mix
|
||||
recording.save!(validate:false)
|
||||
end
|
||||
|
||||
desc "Fill database with music session sample data"
|
||||
task populate_music_sessions: :environment do
|
||||
make_users(10) if 14 > User.count
|
||||
|
|
@ -187,3 +228,32 @@ def make_friends
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def make_recorded_track(recording, user, instrument, md5, length, filename)
|
||||
recorded_track = RecordedTrack.new
|
||||
recorded_track.user = user
|
||||
recorded_track.instrument = Instrument.find(instrument)
|
||||
recorded_track.sound = 'stereo'
|
||||
recorded_track.client_id = user.id
|
||||
recorded_track.client_track_id = SecureRandom.uuid
|
||||
recorded_track.track_id = SecureRandom.uuid
|
||||
recorded_track.md5 = md5
|
||||
recorded_track.length = length
|
||||
recorded_track[:url] = filename
|
||||
recorded_track.fully_uploaded = true
|
||||
recorded_track.is_skip_mount_uploader = true
|
||||
recording.recorded_tracks << recorded_track
|
||||
end
|
||||
|
||||
def make_claimed_recording(recording, user, name, description)
|
||||
claimed_recording = ClaimedRecording.new
|
||||
claimed_recording.user = user
|
||||
claimed_recording.name = name
|
||||
claimed_recording.description = description
|
||||
claimed_recording.is_public = true
|
||||
claimed_recording.is_downloadable = true
|
||||
claimed_recording.genre = Genre.first
|
||||
recording.claimed_recordings << claimed_recording
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue