Skip to content

Commit 5a72147

Browse files
authored
disable pagination if using standalone bbb server (#419)
1 parent 5f9550e commit 5a72147

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

app/controllers/concerns/bbb_helper.rb

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,25 +150,26 @@ def recordings(page = 1)
150150
res ||= bbb.get_recordings(meetingID: @chosen_room.handler, offset: offset, limit: RECORDINGS_PER_PAGE) # offset and limit are for pagination purposes
151151
end
152152

153-
@num_of_recs = res[:totalElements]&.to_i
153+
# When using a BBB server rather than the LB, pagination fails because the format is different,
154+
# and because the BBB server returns an incorrect number of totalElements.
155+
# The LB returns :totalElements, so we use that to check if we are using the LB
156+
# If not, we want to disable pagination
157+
# This is a temporary solution until the pagination logic is fixed in the BBB server.
158+
if res[:totalElements]
159+
@num_of_recs = res[:totalElements].to_i
160+
else
161+
res = bbb.get_recordings(meetingID: @chosen_room.handler)
162+
@num_of_recs = res.length
163+
@disable_pagination = true
164+
end
165+
154166
recordings_formatted(res)
155167
end
156168

157169
def paginate?
158-
return true if @num_of_recs && @num_of_recs > RECORDINGS_PER_PAGE
159-
160-
recordings_count > RECORDINGS_PER_PAGE
161-
end
170+
return false if @disable_pagination
162171

163-
# This method is used if #@num_of_recs is null, which means that totalElements is not present in the BBB response.
164-
# Pull the rest of the recordings to see if we need to paginate.
165-
# Set offset to 8 because we know that at least one page was already pulled.
166-
# Set the limit to the max number of recordings that can be pulled.
167-
def recordings_count
168-
res_count = Rails.cache.fetch("rooms/#{@chosen_room.handler}/#{RECORDINGS_KEY}/remaining", expires_in: Rails.configuration.cache_expires_in_minutes.minutes) if Rails.configuration.cache_enabled
169-
res_count ||= bbb.get_recordings(meetingID: @chosen_room.handler, offset: RECORDINGS_PER_PAGE, limit: 100)[:recordings].length
170-
@num_of_recs = res_count + RECORDINGS_PER_PAGE # We add RECORDINGS_PER_PAGE because we set the offset to 1
171-
@num_of_recs
172+
@num_of_recs > RECORDINGS_PER_PAGE
172173
end
173174

174175
# returns the amount of pages for recordings

0 commit comments

Comments
 (0)