* VRFS-1140
This commit is contained in:
parent
7449de7aad
commit
ec0eb4bb2a
|
|
@ -41,12 +41,13 @@ class MixUploader < CarrierWave::Uploader::Base
|
|||
# JamRecordingId=438
|
||||
# JamMixId=438
|
||||
# JamType=Mix
|
||||
# secret sauce is -codec copy, and a bunch of -metadata arguments.
|
||||
# secret sauce is -codec copy (or -acodec), and a bunch of -metadata arguments.
|
||||
# after done, stomp input file with new one
|
||||
|
||||
input_file = current_path
|
||||
output_file = current_path + '.new.ogg'
|
||||
ffmpeg_cmd = "#{APP_CONFIG.ffmpeg_path} -i \"#{input_file}\" -codec copy -metadata JamRecordingId=#{model.recording_id} -metadata JamMixId=#{model.id} -metadata JamType=Mix \"#{output_file}\""
|
||||
codec_param = RUBY_PLATFORM.include?('darwin') ? 'codec' : 'acodec'
|
||||
ffmpeg_cmd = "#{APP_CONFIG.ffmpeg_path} -i \"#{input_file}\" -#{codec_param} copy -metadata JamRecordingId=#{model.recording_id} -metadata JamMixId=#{model.id} -metadata JamType=Mix \"#{output_file}\""
|
||||
system(ffmpeg_cmd)
|
||||
|
||||
unless $? == 0
|
||||
|
|
|
|||
|
|
@ -18,12 +18,13 @@ class RecordedTrackUploader < CarrierWave::Uploader::Base
|
|||
#JamClientId=8331bcec-7810-42c1-9f39-a5c129406e85
|
||||
#JamType=LocalTrack
|
||||
|
||||
# secret sauce is -codec copy, and a bunch of -metadata arguments.
|
||||
# secret sauce is -codec copy (or -acodec), and a bunch of -metadata arguments
|
||||
# after done, stomp input file with new one
|
||||
|
||||
input_file = current_path
|
||||
output_file = current_path + '.new.ogg'
|
||||
ffmpeg_cmd = "#{APP_CONFIG.ffmpeg_path} -i \"#{input_file}\" -codec copy -metadata JamRecordingId=#{model.recording_id} -metadata JamTrackId=#{model.client_track_id} -metadata JamClientId=#{model.client_id} -metadata JamType=LocalTrack \"#{output_file}\""
|
||||
codec_param = RUBY_PLATFORM.include?('darwin') ? 'codec' : 'acodec'
|
||||
ffmpeg_cmd = "#{APP_CONFIG.ffmpeg_path} -i \"#{input_file}\" -#{codec_param} copy -metadata JamRecordingId=#{model.recording_id} -metadata JamTrackId=#{model.client_track_id} -metadata JamClientId=#{model.client_id} -metadata JamType=LocalTrack \"#{output_file}\""
|
||||
system(ffmpeg_cmd)
|
||||
|
||||
unless $? == 0
|
||||
|
|
|
|||
|
|
@ -7,26 +7,38 @@ module JamRuby
|
|||
|
||||
FIXNUM_MAX = (2**(0.size * 8 -2) -1)
|
||||
SORT_TYPES = ['date', 'plays', 'likes']
|
||||
TIME_RANGES = ['today', 'week', 'month', 'all']
|
||||
TYPE_FILTERS = ['session', 'recording', 'all']
|
||||
|
||||
def self.index(params = {limit:20, sort: 'date'})
|
||||
def self.index(params = {})
|
||||
limit = params[:limit]
|
||||
limit ||= 20
|
||||
limit = limit.to_i
|
||||
|
||||
# validate sort
|
||||
sort = params[:sort]
|
||||
sort ||= 'date'
|
||||
raise "not valid sort #{sort}" unless SORT_TYPES.include?(sort)
|
||||
|
||||
|
||||
start = params[:start]
|
||||
if sort == 'date'
|
||||
start ||= FIXNUM_MAX
|
||||
else
|
||||
start ||= 0
|
||||
end
|
||||
start = start.to_i
|
||||
|
||||
time_range = params[:time_range]
|
||||
time_range ||= 'month'
|
||||
raise "not valid time_range #{time_range}" unless TIME_RANGES.include?(time_range)
|
||||
|
||||
type_filter = params[:type]
|
||||
type_filter ||= 'all'
|
||||
raise "not valid type #{type_filter}" unless TYPE_FILTERS.include?(type_filter)
|
||||
|
||||
query = Feed.includes([:recording]).includes([:music_session_history]).limit(limit)
|
||||
|
||||
# handle sort
|
||||
if sort == 'date'
|
||||
query = query.where("id < #{start}")
|
||||
query = query.order('id DESC')
|
||||
|
|
@ -40,7 +52,14 @@ module JamRuby
|
|||
raise "sort not implemented: #{sort}"
|
||||
end
|
||||
|
||||
#query = query.order('claimed_recordings.created_at')
|
||||
# handle time range
|
||||
|
||||
# handle type filters
|
||||
if type_filter == 'session'
|
||||
query = query.where('music_session_id is not NULL')
|
||||
elsif type_filter == 'recording'
|
||||
query = query.where('recording_id is not NULL')
|
||||
end
|
||||
|
||||
if query.length == 0
|
||||
[query, nil]
|
||||
|
|
|
|||
|
|
@ -109,6 +109,25 @@ describe Feed do
|
|||
end
|
||||
end
|
||||
|
||||
describe "type filters" do
|
||||
it "returns only sessions" do
|
||||
# creates both recording and history record in feed
|
||||
claimed_recording1 = FactoryGirl.create(:claimed_recording)
|
||||
|
||||
feeds, start = Feed.index(:type => 'session')
|
||||
feeds.length.should == 1
|
||||
feeds[0].music_session_history == claimed_recording1.recording.music_session.music_session_history
|
||||
end
|
||||
|
||||
it "returns only sessions" do
|
||||
# creates both recording and history record in feed
|
||||
claimed_recording1 = FactoryGirl.create(:claimed_recording)
|
||||
|
||||
feeds, start = Feed.index(:type => 'session')
|
||||
feeds.length.should == 1
|
||||
feeds[0].music_session_history == claimed_recording1.recording.music_session.music_session_history
|
||||
end
|
||||
end
|
||||
describe "pagination" do
|
||||
it "supports date pagination" do
|
||||
claimed_recording = FactoryGirl.create(:claimed_recording)
|
||||
|
|
@ -170,6 +189,7 @@ describe Feed do
|
|||
feeds.length.should == 0
|
||||
start.should be_nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ class ApiFeedsController < ApiController
|
|||
@feeds, @next = Feed.index(user: current_user,
|
||||
start: params[:since],
|
||||
limit: params[:limit],
|
||||
sort: params[:sort])
|
||||
sort: params[:sort],
|
||||
time_range: params[:time_range])
|
||||
|
||||
render "api_feeds/index", :layout => nil
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue