Skip to content

Commit

Permalink
LTI-415: implement pagination with new totalElements value returned (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariam05 authored Dec 10, 2024
1 parent 24931b6 commit 2feb274
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions app/controllers/concerns/bbb_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,17 @@ def recordings(page = 1)
res = Rails.cache.fetch("rooms/#{@chosen_room.handler}/#{RECORDINGS_KEY}", expires_in: Rails.configuration.cache_expires_in_minutes.minutes) if Rails.configuration.cache_enabled
offset = (page.to_i - 1) * RECORDINGS_PER_PAGE # The offset is an index that starts at 0.
res ||= bbb.get_recordings(meetingID: @chosen_room.handler, offset: offset, limit: RECORDINGS_PER_PAGE) # offset and limit are for pagination purposes
@num_of_recs = res[:totalElements]&.to_i
recordings_formatted(res)
end

def recordings_count
res = Rails.cache.fetch("rooms/#{@chosen_room.handler}/#{RECORDINGS_KEY}", expires_in: Rails.configuration.cache_expires_in_minutes.minutes) if Rails.configuration.cache_enabled
res ||= bbb.get_recordings(meetingID: @chosen_room.handler)
res[:recordings].length
end

def paginate?
recordings_count > RECORDINGS_PER_PAGE
@num_of_recs ? @num_of_recs > RECORDINGS_PER_PAGE : false
end

# returns the amount of pages for recordings
def pages_count
(recordings_count.to_f / RECORDINGS_PER_PAGE).ceil
@num_of_recs ? (@num_of_recs.to_f / RECORDINGS_PER_PAGE).ceil : 1
end

# on the last page, we don't want recordings that were in the second-to-last page to show
Expand Down

0 comments on commit 2feb274

Please sign in to comment.