Skip to content

Commit

Permalink
Added POLL_DELAY environment variable to UserConfiguration class
Browse files Browse the repository at this point in the history
  • Loading branch information
abujeda committed Mar 14, 2024
1 parent 8a7bf69 commit 71a2c83
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion apps/dashboard/app/models/user_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ class UserConfiguration
# Custom pages configuration property
ConfigurationProperty.property(name: :custom_pages, default_value: {}),
# Support ticket configuration property
ConfigurationProperty.property(name: :support_ticket, default_value: {})
ConfigurationProperty.property(name: :support_ticket, default_value: {}),

# Session cards job information update poll waiting time in milliseconds
ConfigurationProperty.property(name: :sessions_poll_delay, default_value: '10000', read_from_env: true,
env_names: ['POLL_DELAY'])
].freeze

def initialize(request_hostname: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ locals: {
%>
</div>
<div class="col-md-9">
<div id="batch_connect_sessions" class="batch-connect sessions" data-toggle="poll" data-url="<%= batch_connect_sessions_path(format: :js) %>" data-delay="<%= ENV["POLL_DELAY"] || 10000 %>">
<div id="batch_connect_sessions" class="batch-connect sessions" data-toggle="poll" data-url="<%= batch_connect_sessions_path(format: :js) %>" data-delay="<%= @user_configuration.sessions_poll_delay %>">
<% if @sessions.empty? %>
<div class="ood-appkit markdown">
<p><%= t('dashboard.batch_connect_no_sessions') %></p>
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/app/views/widgets/_sessions.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%-
max_sessions = 3
poll_delay = ENV["POLL_DELAY"] || 10000
poll_delay = @user_configuration.sessions_poll_delay
active_sessions = BatchConnect::Session.all.reject { |s| s.completed? }
session_selection = active_sessions.first(max_sessions)
-%>
Expand Down
2 changes: 2 additions & 0 deletions apps/dashboard/test/models/user_configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class UserConfigurationTest < ActiveSupport::TestCase
'OOD_ANNOUNCEMENT_PATH' => [:announcement_path, Pathname.new("/#{SecureRandom.uuid}")],

'SHOW_ALL_APPS_LINK' => [:show_all_apps_link, true],
'POLL_DELAY' => [:sessions_poll_delay, '10000'],
}

def setup()
Expand Down Expand Up @@ -79,6 +80,7 @@ def teardown
interactive_apps_menu: [],
custom_pages: {},
support_ticket: {},
sessions_poll_delay: '10000',
}

# ensure all properties are tested
Expand Down

0 comments on commit 71a2c83

Please sign in to comment.