forked from External/greenlight
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.
|
# Helper for converting BigBlueButton dates into a nice length string.
|
||||||
def recording_length(playbacks)
|
def recording_length(playbacks)
|
||||||
# Stats format currently doesn't support length.
|
# Looping through playbacks array and returning first non-zero length value
|
||||||
valid_playbacks = playbacks.reject { |p| p[:type] == "statistics" }
|
playbacks.each do |playback|
|
||||||
return "0 min" if valid_playbacks.empty?
|
length = playback[:length]
|
||||||
|
return recording_length_string(length) unless length.zero?
|
||||||
len = valid_playbacks.first[:length]
|
|
||||||
if len > 60
|
|
||||||
"#{(len / 60).to_i} h #{len % 60} min"
|
|
||||||
elsif len.zero?
|
|
||||||
"< 1 min"
|
|
||||||
else
|
|
||||||
"#{len} min"
|
|
||||||
end
|
end
|
||||||
|
# Return '< 1 min' if length values are zero
|
||||||
|
"< 1 min"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Prevents single images from erroring when not passed as an array.
|
# Prevents single images from erroring when not passed as an array.
|
||||||
|
@ -51,4 +46,15 @@ module RecordingsHelper
|
||||||
def recording_thumbnails?
|
def recording_thumbnails?
|
||||||
Rails.configuration.recording_thumbnails
|
Rails.configuration.recording_thumbnails
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue