From 19b61f2d26a12ed23212e6a769fd683a7ce88761 Mon Sep 17 00:00:00 2001 From: Mariam05 Date: Mon, 9 Dec 2024 16:30:52 -0500 Subject: [PATCH] LTI-413: don't do unnecessary db updates --- Gemfile.lock | 280 ++++++++++++------------- app/controllers/concerns/bbb_helper.rb | 11 +- app/jobs/room_meeting_watcher_job.rb | 8 +- 3 files changed, 144 insertions(+), 155 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 40179b05..5b6d8a37 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,52 +10,52 @@ GEM specs: action-cable-testing (0.6.1) actioncable (>= 5.0) - actioncable (6.1.7.8) - actionpack (= 6.1.7.8) - activesupport (= 6.1.7.8) + actioncable (6.1.7.10) + actionpack (= 6.1.7.10) + activesupport (= 6.1.7.10) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.8) - actionpack (= 6.1.7.8) - activejob (= 6.1.7.8) - activerecord (= 6.1.7.8) - activestorage (= 6.1.7.8) - activesupport (= 6.1.7.8) + actionmailbox (6.1.7.10) + actionpack (= 6.1.7.10) + activejob (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) mail (>= 2.7.1) - actionmailer (6.1.7.8) - actionpack (= 6.1.7.8) - actionview (= 6.1.7.8) - activejob (= 6.1.7.8) - activesupport (= 6.1.7.8) + actionmailer (6.1.7.10) + actionpack (= 6.1.7.10) + actionview (= 6.1.7.10) + activejob (= 6.1.7.10) + activesupport (= 6.1.7.10) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.7.8) - actionview (= 6.1.7.8) - activesupport (= 6.1.7.8) + actionpack (6.1.7.10) + actionview (= 6.1.7.10) + activesupport (= 6.1.7.10) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.8) - actionpack (= 6.1.7.8) - activerecord (= 6.1.7.8) - activestorage (= 6.1.7.8) - activesupport (= 6.1.7.8) + actiontext (6.1.7.10) + actionpack (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) nokogiri (>= 1.8.5) - actionview (6.1.7.8) - activesupport (= 6.1.7.8) + actionview (6.1.7.10) + activesupport (= 6.1.7.10) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.8) - activesupport (= 6.1.7.8) + activejob (6.1.7.10) + activesupport (= 6.1.7.10) globalid (>= 0.3.6) - activemodel (6.1.7.8) - activesupport (= 6.1.7.8) - activerecord (6.1.7.8) - activemodel (= 6.1.7.8) - activesupport (= 6.1.7.8) + activemodel (6.1.7.10) + activesupport (= 6.1.7.10) + activerecord (6.1.7.10) + activemodel (= 6.1.7.10) + activesupport (= 6.1.7.10) activerecord-session_store (2.1.0) actionpack (>= 6.1) activerecord (>= 6.1) @@ -63,14 +63,14 @@ GEM multi_json (~> 1.11, >= 1.11.2) rack (>= 2.0.8, < 4) railties (>= 6.1) - activestorage (6.1.7.8) - actionpack (= 6.1.7.8) - activejob (= 6.1.7.8) - activerecord (= 6.1.7.8) - activesupport (= 6.1.7.8) + activestorage (6.1.7.10) + actionpack (= 6.1.7.10) + activejob (= 6.1.7.10) + activerecord (= 6.1.7.10) + activesupport (= 6.1.7.10) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.8) + activesupport (6.1.7.10) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -102,8 +102,9 @@ GEM regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) cgi (0.4.1) - childprocess (5.0.0) - concurrent-ruby (1.3.3) + childprocess (5.1.0) + logger (~> 1.5) + concurrent-ruby (1.3.4) coveralls_reborn (0.28.0) simplecov (~> 0.22.0) term-ansicolor (~> 1.7) @@ -113,54 +114,56 @@ GEM bigdecimal rexml crass (1.0.6) - database_cleaner-active_record (2.1.0) + database_cleaner-active_record (2.2.0) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.3.4) + date (3.4.1) diff-lcs (1.5.1) - docile (1.4.0) + docile (1.4.1) domain_name (0.6.20240107) - dotenv (3.1.2) - dotenv-rails (3.1.2) - dotenv (= 3.1.2) + dotenv (3.1.4) + dotenv-rails (3.1.4) + dotenv (= 3.1.4) railties (>= 6.1) erubi (1.13.0) - execjs (2.9.1) - factory_bot (6.4.6) + execjs (2.10.0) + factory_bot (6.5.0) activesupport (>= 5.0.0) - factory_bot_rails (6.4.3) - factory_bot (~> 6.4) + factory_bot_rails (6.4.4) + factory_bot (~> 6.5) railties (>= 5.0.0) - faker (3.4.1) + faker (3.5.1) i18n (>= 1.8.11, < 2) - faraday (2.10.0) - faraday-net_http (>= 2.0, < 3.2) + faraday (2.12.1) + faraday-net_http (>= 2.0, < 3.5) + json logger - faraday-net_http (3.1.0) - net-http + faraday-net_http (3.4.0) + net-http (>= 0.5.0) ffi (1.17.0) + ffi (1.17.0-x86_64-linux-gnu) globalid (1.2.1) activesupport (>= 6.1) - hashdiff (1.1.0) + hashdiff (1.1.2) hashie (5.0.0) http-accept (1.7.0) - http-cookie (1.0.6) + http-cookie (1.0.8) domain_name (~> 0.5) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) - jbuilder (2.12.0) + jbuilder (2.13.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) - json (2.7.2) - jwt (2.8.2) + json (2.9.0) + jwt (2.9.3) base64 language_server-protocol (3.17.0.3) listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) little-plugger (1.1.4) - logger (1.6.0) + logger (1.6.2) logging (2.4.0) little-plugger (~> 1.1) multi_json (~> 1.14) @@ -169,7 +172,7 @@ GEM activesupport (>= 4) railties (>= 4) request_store (~> 1.0) - loofah (2.22.0) + loofah (2.23.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -180,21 +183,20 @@ GEM marcel (1.0.4) matrix (0.4.2) method_source (1.1.0) - mime-types (3.5.2) + mime-types (3.6.0) + logger mime-types-data (~> 3.2015) - mime-types-data (3.2024.0702) + mime-types-data (3.2024.1203) mini_mime (1.1.5) - mini_portile2 (2.8.7) - minitest (5.24.1) - mize (0.4.1) - protocol (~> 2.0) + mini_portile2 (2.8.8) + minitest (5.25.4) multi_json (1.15.0) multi_xml (0.7.1) bigdecimal (~> 3.1) - mutex_m (0.2.0) - net-http (0.4.1) + mutex_m (0.3.0) + net-http (0.6.0) uri - net-imap (0.4.14) + net-imap (0.5.1) date net-protocol net-pop (0.1.2) @@ -204,11 +206,11 @@ GEM net-smtp (0.5.0) net-protocol netrc (0.11.0) - nio4r (2.7.3) - nokogiri (1.16.6) + nio4r (2.7.4) + nokogiri (1.16.8) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.16.6-x86_64-linux) + nokogiri (1.16.8-x86_64-linux) racc (~> 1.4) oauth2 (2.0.9) faraday (>= 0.17.3, < 3.0) @@ -227,21 +229,20 @@ GEM omniauth-rails_csrf_protection (1.0.2) actionpack (>= 4.2) omniauth (~> 2.0) - pagy (8.6.3) - parallel (1.25.1) - parser (3.3.4.0) + pagy (9.3.2) + parallel (1.26.3) + parser (3.3.6.0) ast (~> 2.4.1) racc - pg (1.5.6) - protocol (2.0.0) - ruby_parser (~> 3.0) - psych (5.1.2) + pg (1.5.9) + psych (5.2.1) + date stringio - public_suffix (6.0.0) - puma (5.6.8) + public_suffix (6.0.1) + puma (5.6.9) nio4r (~> 2.0) - racc (1.8.0) - rack (2.2.9) + racc (1.8.1) + rack (2.2.10) rack-protection (3.2.0) base64 (>= 0.1.0) rack (~> 2.2, >= 2.2.4) @@ -249,20 +250,20 @@ GEM rack rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.8) - actioncable (= 6.1.7.8) - actionmailbox (= 6.1.7.8) - actionmailer (= 6.1.7.8) - actionpack (= 6.1.7.8) - actiontext (= 6.1.7.8) - actionview (= 6.1.7.8) - activejob (= 6.1.7.8) - activemodel (= 6.1.7.8) - activerecord (= 6.1.7.8) - activestorage (= 6.1.7.8) - activesupport (= 6.1.7.8) + rails (6.1.7.10) + actioncable (= 6.1.7.10) + actionmailbox (= 6.1.7.10) + actionmailer (= 6.1.7.10) + actionpack (= 6.1.7.10) + actiontext (= 6.1.7.10) + actionview (= 6.1.7.10) + activejob (= 6.1.7.10) + activemodel (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) bundler (>= 1.15.0) - railties (= 6.1.7.8) + railties (= 6.1.7.10) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -272,12 +273,12 @@ GEM activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) + rails-html-sanitizer (1.6.1) loofah (~> 2.21) - nokogiri (~> 1.14) - railties (6.1.7.8) - actionpack (= 6.1.7.8) - activesupport (= 6.1.7.8) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + railties (6.1.7.10) + actionpack (= 6.1.7.10) + activesupport (= 6.1.7.10) method_source rake (>= 12.2) thor (~> 1.0) @@ -286,10 +287,10 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rdoc (6.7.0) + rdoc (6.8.1) psych (>= 4.0.0) redis (4.8.1) - regexp_parser (2.9.2) + regexp_parser (2.9.3) remote_syslog_logger (1.0.4) syslog_protocol repost (0.4.2) @@ -300,18 +301,17 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.3.1) - strscan + rexml (3.3.9) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) + rspec-core (3.13.2) rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.1) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-rails (6.0.4) @@ -322,31 +322,27 @@ GEM rspec-expectations (~> 3.12) rspec-mocks (~> 3.12) rspec-support (~> 3.12) - rspec-support (3.13.1) + rspec-support (3.13.2) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.65.0) + rubocop (1.69.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.4, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.31.1, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.36.2, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.3) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.36.2) parser (>= 3.3.1.0) - rubocop-rails (2.25.1) + rubocop-rails (2.27.0) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) + rubocop (>= 1.52.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (1.13.0) - ruby_parser (3.21.1) - racc (~> 1.5) - sexp_processor (~> 4.16) rubyzip (2.3.2) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) @@ -358,19 +354,18 @@ GEM sprockets (> 3.0) sprockets-rails tilt - selenium-webdriver (4.23.0) + selenium-webdriver (4.27.0) base64 (~> 0.2) logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - semantic_range (3.0.0) - sexp_processor (4.17.2) + semantic_range (3.1.0) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) + simplecov-html (0.13.1) simplecov_json_formatter (0.1.4) snaky_hash (2.0.1) hashie @@ -382,22 +377,20 @@ GEM sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) - sprockets-rails (3.5.1) + sprockets-rails (3.5.2) actionpack (>= 6.1) activesupport (>= 6.1) sprockets (>= 3.0.0) - stringio (3.1.1) - strscan (3.1.0) + stringio (3.1.2) sync (0.5.0) - syslog (0.1.0) + syslog (0.1.2) syslog_protocol (0.9.2) - term-ansicolor (1.10.2) - mize + term-ansicolor (1.11.2) tins (~> 1.0) - thor (1.3.1) + thor (1.3.2) tilt (2.4.0) - timeout (0.4.1) - tins (1.33.0) + timeout (0.4.2) + tins (1.37.0) bigdecimal sync turbolinks (5.2.1) @@ -405,12 +398,14 @@ GEM turbolinks-source (5.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - tzinfo-data (1.2024.1) + tzinfo-data (1.2024.2) tzinfo (>= 1.0.0) - uglifier (4.2.0) + uglifier (4.2.1) execjs (>= 0.3.0, < 3) - unicode-display_width (2.5.0) - uri (0.13.0) + unicode-display_width (3.1.2) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) + uri (1.0.2) version_gem (1.1.4) web-console (4.2.1) actionview (>= 6.0.0) @@ -421,7 +416,7 @@ GEM nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (~> 4.0) - webmock (3.23.1) + webmock (3.24.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) @@ -438,7 +433,7 @@ GEM rexml xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.16) + zeitwerk (2.7.1) PLATFORMS ruby @@ -495,3 +490,6 @@ DEPENDENCIES webdrivers webmock (>= 3.20.0) webpacker (~> 6.0.0.rc.5) + +BUNDLED WITH + 2.5.11 diff --git a/app/controllers/concerns/bbb_helper.rb b/app/controllers/concerns/bbb_helper.rb index ed3cefcb..b2169ee7 100644 --- a/app/controllers/concerns/bbb_helper.rb +++ b/app/controllers/concerns/bbb_helper.rb @@ -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 diff --git a/app/jobs/room_meeting_watcher_job.rb b/app/jobs/room_meeting_watcher_job.rb index 561e25a9..05139af4 100644 --- a/app/jobs/room_meeting_watcher_job.rb +++ b/app/jobs/room_meeting_watcher_job.rb @@ -11,7 +11,7 @@ def perform(room, data) info = fetch_meeting_info(data) if info[:meeting_in_progress] - @chosen_room.update(watcher_job_active: true) + @chosen_room.update(watcher_job_active: true) unless @chosen_room.watcher_job_active # no need to update if it's already true logger.info("Meeting in progress. Sending broadcast to room '#{room.name}'") # Broadcast updates to this room’s channel @@ -24,7 +24,7 @@ def perform(room, data) # Broadcast that the meeting ended MeetingInfoChannel.broadcast_to(room, { meeting_in_progress: false, action: 'end' }) - @chosen_room.update(watcher_job_active: false) + @chosen_room.update(watcher_job_active: false) if @chosen_room.watcher_job_active # no need to update if it's already false # Do not re-enqueue, job ends here end end @@ -42,8 +42,4 @@ def fetch_meeting_info(data) data[:participant_count] = info[:participantCount] data end - - def meeting_running?(info) - info[:returncode] == 'SUCCESS' && info[:running] == true - end end