* add gift card image

This commit is contained in:
Seth Call 2015-11-30 05:07:47 -06:00
parent 6f488d4692
commit 7f0fd988ce
5 changed files with 79 additions and 3 deletions

View File

@ -34,6 +34,42 @@ module JamRuby
self.detail = detail
end
def import_click_track(jam_track)
# we need to download the click track, if it exists.
Dir.mktmpdir do |tmp_dir|
click_track_file = jam_track.click_track_file
if click_track_file.nil?
@@log.info("no click track for #{jam_track.name}:#{jam_track.name}")
finish('success', 'no_click_track')
return
end
click_track_file = File.join(tmp_dir, File.basename(click_track_file[:original_filename]))
JamTrackImporter.song_storage_manager.download(click_track_file[:original_filename], click_track_file)
JamTrack.transaction do
click_track = jam_track.click_track
if click_track.nil?
click_track = JamTrackTrack.new
#track.original_filename = wav_file
#track.original_audio_s3_path = wav_file
track.track_type = 'Click'
track.part = 'Click'
track.instrument_id = 'computer'
track.jam_track = jam_track
if !track.save
finish("jam_track_click", "unable to create: #{track.errors}")
end
end
# with the click track in hand, flesh out the details
end
end
def generate_jmep(jam_track)
if !jam_track.blank?
finish('success', 'jmep already exists')
@ -44,7 +80,7 @@ module JamRuby
master_track = jam_track.master_track
click_track = jam_track.click_track
click_track = jam_track.click_track_file
if master_track.nil?
finish('no_master_track', nil)
@ -2036,6 +2072,13 @@ module JamRuby
end
end
def import_click_track(jam_track)
importer = JamTrackImporter.new
importer.name = jam_track.name
importer.import_click_track(jam_track)
importer
end
def generate_jmep(jam_track)
importer = JamTrackImporter.new
importer.name = jam_track.name
@ -2044,6 +2087,31 @@ module JamRuby
importer
end
def import_click_tracks
importers = []
JamTrack.all.each do |jam_track|
importers << import_click_track(jam_track)
end
@@log.info("SUMMARY")
@@log.info("-------")
importers.each do |importer|
if importer
if importer.reason == "success"
@@log.info("#{importer.name} #{importer.reason}")
else
@@log.error("#{importer.name} failed to generate jmep.")
@@log.error("#{importer.name} reason=#{importer.reason}")
@@log.error("#{importer.name} detail=#{importer.detail}")
end
else
@@log.error("NULL IMPORTER")
end
end
end
def generate_jmeps
importers = []

View File

@ -435,9 +435,12 @@ module JamRuby
end
end
def click_track_file
JamTrackFile.where(jam_track_id: self.id).where(file_type: 'ClickWav').first
end
def click_track
JamTrackFile.where(jam_track_id: self.id).where(file_type: 'ClickWav').first
JamTrackTrack.where(jam_track_id: self.id).where(track_type: 'Click').first
end
def master_track

View File

@ -6,7 +6,7 @@ module JamRuby
include JamRuby::S3PublicManagerMixin
# there should only be one Master per JamTrack, but there can be N Track per JamTrack
TRACK_TYPE = %w{Track Master}
TRACK_TYPE = %w{Track Master Click}
@@log = Logging.logger[JamTrackTrack]

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 KiB

View File

@ -1,5 +1,10 @@
namespace :jam_tracks do
task import_click_tracks: :environment do |task, args|
JamTrackImporter.storage_format = 'Tency'
JamTrackImporter.import_click_tracks
end
task generate_jmep: :environment do |task, args|
JamTrackImporter.storage_format = 'Tency'
JamTrackImporter.generate_jmeps