diff --git a/apps/dashboard/app/views/batch_connect/sessions/index.html.erb b/apps/dashboard/app/views/batch_connect/sessions/index.html.erb index e916b74597..a637ce4971 100644 --- a/apps/dashboard/app/views/batch_connect/sessions/index.html.erb +++ b/apps/dashboard/app/views/batch_connect/sessions/index.html.erb @@ -34,7 +34,7 @@ locals: { %>
<%= t('dashboard.batch_connect_no_sessions') %>
diff --git a/apps/dashboard/app/views/widgets/_sessions.html.erb b/apps/dashboard/app/views/widgets/_sessions.html.erb index d7bb7a82a8..71f8fafa08 100644 --- a/apps/dashboard/app/views/widgets/_sessions.html.erb +++ b/apps/dashboard/app/views/widgets/_sessions.html.erb @@ -1,6 +1,6 @@ <%- max_sessions = 3 - poll_delay = ENV["POLL_DELAY"] || 10000 + poll_delay = Configuration.bc_sessions_poll_delay active_sessions = BatchConnect::Session.all.reject { |s| s.completed? } session_selection = active_sessions.first(max_sessions) -%> diff --git a/apps/dashboard/config/configuration_singleton.rb b/apps/dashboard/config/configuration_singleton.rb index 3873bc418c..bf16ab7c8d 100644 --- a/apps/dashboard/config/configuration_singleton.rb +++ b/apps/dashboard/config/configuration_singleton.rb @@ -368,6 +368,15 @@ def ood_bc_card_time (ood_bc_card_time_int < 0) ? 0 : ood_bc_card_time_int end + # Returns the number of milliseconds to wait between calls to the BatchConnect Sessions resource + # to update the sessions card information. + # The default and minimum value is 10s = 10_000 + def bc_sessions_poll_delay + bc_poll_delay = ENV['POLL_DELAY'] + bc_poll_delay_int = bc_poll_delay.nil? ? config.fetch(:sessions_poll_delay, '10000').to_i : bc_poll_delay.to_i + bc_poll_delay_int < 10_000 ? 10_000 : bc_poll_delay_int + end + def config @config ||= read_config end diff --git a/apps/dashboard/test/config/configuration_singleton_test.rb b/apps/dashboard/test/config/configuration_singleton_test.rb index 5f6c452278..4aa3ccd231 100644 --- a/apps/dashboard/test/config/configuration_singleton_test.rb +++ b/apps/dashboard/test/config/configuration_singleton_test.rb @@ -496,4 +496,31 @@ def no_config_env end end end + + test "bc_sessions_poll_delay default value" do + assert_equal(10_000, ConfigurationSingleton.new.bc_sessions_poll_delay) + end + + test "bc_sessions_poll_delay reads value from environment" do + with_modified_env('POLL_DELAY': '20000') do + assert_equal(20_000, ConfigurationSingleton.new.bc_sessions_poll_delay) + end + end + + test 'bc_sessions_poll_delay reads from config' do + Dir.mktmpdir do |dir| + with_modified_env({ OOD_CONFIG_D_DIRECTORY: dir.to_s }) do + sessions_config = { 'sessions_poll_delay' => '99999' } + File.open("#{dir}/sessions_config.yml", 'w+') { |f| f.write(sessions_config.to_yaml) } + + assert_equal(99_999, ConfigurationSingleton.new.bc_sessions_poll_delay) + end + end + end + + test "bc_sessions_poll_delay minimum value is 10_000" do + with_modified_env('POLL_DELAY': '100') do + assert_equal(10_000, ConfigurationSingleton.new.bc_sessions_poll_delay) + end + end end