-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove display mime type and migrate existing data to new fields
- Loading branch information
Showing
8 changed files
with
51 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
json.extract! recording, :size, :length, :mime_type, :language, :filename, :original_url, :state, :folder, :width, :height, :updated_at | ||
json.recording_url recording.get_recording_url | ||
json.hd recording.hd_quality | ||
json.display_mime_type MimeType.display_mime_type(recording.mime_type) | ||
json.url public_recording_url(recording, format: :json) | ||
json.event_url public_event_url(recording.event, format: :json) | ||
json.conference_url public_conference_url(recording.conference, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class MimeTypesToFlags < ActiveRecord::Migration | ||
def change | ||
html5 = %w(vnd.voc/mp4-web vnd.voc/webm-web) | ||
Recording.find_each do |recording| | ||
next unless recording.valid? | ||
recording.hd_quality = hd?(recording.mime_type) | ||
recording.html5 = html5.include?(recording.mime_type) | ||
recording.mime_type = display_mime_type(recording.mime_type) | ||
recording.save! | ||
end | ||
end | ||
|
||
def display_mime_type(mime_type) | ||
case mime_type | ||
when 'vnd.voc/h264-lq' | ||
'video/mp4' | ||
when 'vnd.voc/h264-sd' | ||
'video/mp4' | ||
when 'vnd.voc/h264-hd' | ||
'video/mp4' | ||
when 'vnd.voc/mp4-web' | ||
'video/mp4' | ||
when 'vnd.voc/webm-hd' | ||
'video/webm' | ||
when 'vnd.voc/webm-web' | ||
'video/webm' | ||
else | ||
mime_type | ||
end | ||
end | ||
|
||
def hd?(mime_type) | ||
case mime_type | ||
when 'vnd.voc/h264-lq' | ||
false | ||
when 'vnd.voc/h264-sd' | ||
false | ||
when 'vnd.voc/h264-hd' | ||
true | ||
when 'vnd.voc/webm-hd' | ||
true | ||
else | ||
true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters