Skip to content

Commit

Permalink
Improve output filtering and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
masaball committed Jan 28, 2025
1 parent b83f574 commit 048a650
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions app/models/master_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,7 @@ def update_progress_on_success!(encode)
self.display_aspect_ratio = (high_output.width.to_f / high_output.height.to_f).to_s
end

# Supplemental file outputs do not have a label. Use that to identify output type for now.
outputs = Array(encode.output).collect do |output|
outputs = Array(encode.output).reject { |output| output.subtitles.nil? }.collect do |output|
{
id: output.id,
label: output.label,
Expand All @@ -334,10 +333,10 @@ def update_progress_on_success!(encode)
width: output.width,
height: output.height
}
end.reject { |output| output[:label].blank? }
end
update_derivatives(outputs)

supplemental_file_outputs = Array(encode.output).reject { |out| out.label.present? }
supplemental_file_outputs = Array(encode.output).select { |out| out.subtitles.nil? }
supplemental_file_ids = supplemental_file_outputs.collect { |sf| sf.id }.compact
add_supplemental_files(supplemental_file_ids) if supplemental_file_ids.present?

Expand Down
4 changes: 3 additions & 1 deletion spec/factories/encode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
video_codec { 'AVC' }
width { '1024' }
height { '768' }
subtitle_count { 0 }
subtitles { [] }
end

factory :encode_output, class: ActiveEncode::Output do
Expand All @@ -78,10 +78,12 @@
video_codec { 'AVC' }
width { '1024' }
height { '768' }
subtitles { [] }
end

factory :encode_supplemental_output, class: ActiveEncode::Output do
id { 1 }
url { "file://#{Rails.root.join('spec', 'fixtures', 'caption.vtt')}"}
format { "vtt" }
end
end

0 comments on commit 048a650

Please sign in to comment.