GRN2-273: Fixed bug where incorrect recording length returned when "Notes" format was included (#961)
* GRN2-273: Fixed bug where incorrect recording length returned * GRN2-273: Changing iteration variable name in recording_length method
This commit is contained in:
parent
4093a89b4a
commit
b7aa5406ea
@ -24,18 +24,13 @@ module RecordingsHelper
|
||||
|
||||
# Helper for converting BigBlueButton dates into a nice length string.
|
||||
def recording_length(playbacks)
|
||||
# Stats format currently doesn't support length.
|
||||
valid_playbacks = playbacks.reject { |p| p[:type] == "statistics" }
|
||||
return "0 min" if valid_playbacks.empty?
|
||||
|
||||
len = valid_playbacks.first[:length]
|
||||
if len > 60
|
||||
"#{(len / 60).to_i} h #{len % 60} min"
|
||||
elsif len.zero?
|
||||
"< 1 min"
|
||||
else
|
||||
"#{len} min"
|
||||
# Looping through playbacks array and returning first non-zero length value
|
||||
playbacks.each do |playback|
|
||||
length = playback[:length]
|
||||
return recording_length_string(length) unless length.zero?
|
||||
end
|
||||
# Return '< 1 min' if length values are zero
|
||||
"< 1 min"
|
||||
end
|
||||
|
||||
# Prevents single images from erroring when not passed as an array.
|
||||
@ -51,4 +46,15 @@ module RecordingsHelper
|
||||
def recording_thumbnails?
|
||||
Rails.configuration.recording_thumbnails
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Returns length of the recording as a string
|
||||
def recording_length_string(len)
|
||||
if len > 60
|
||||
"#{(len / 60).to_i} h #{len % 60} min"
|
||||
else
|
||||
"#{len} min"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user