Skip to content

Commit

Permalink
NOC for BACs; better CleanCache BAC.
Browse files Browse the repository at this point in the history
  • Loading branch information
prioux committed Apr 18, 2024
1 parent 0a5dcf9 commit 7fc5428
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
11 changes: 11 additions & 0 deletions BrainPortal/app/controllers/noc_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,17 @@ def gather_info(since_when) #:nodoc:
# Number of exceptions
@num_exceptions = ExceptionLog.where([ "created_at > ?", since_when ]).count
@num_exceptions = rand(fake) if fake

# Number of BackgroundActivities (non scheduled) updated
bacs = BackgroundActivity
.where(:status => [ 'InProgress', 'Completed', 'Failed', 'PartiallyCompleted' ])
.where([ "updated_at > ?", since_when ])
.group(:status).count
@num_bacs_progress = bacs['InProgress'] || 0 # in blue
@num_bacs_completed = bacs['Completed'] || 0 # in green
@num_bacs_partial = bacs['PartiallyCompleted'] || 0 # in yellow
@num_bacs_failed = bacs['Failed'] || 0 # in red

end

# Show IP address
Expand Down
14 changes: 10 additions & 4 deletions BrainPortal/app/models/background_activity/clean_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,16 @@ def process(item)

def prepare_dynamic_items
days_older = self.options[:days_older] || DEFAULT_DAYS_OLD
with_user_ids = self.options[:with_user_ids]
without_user_ids = self.options[:without_user_ids]
with_types = self.options[:with_types]
without_types = self.options[:without_types]
with_user_ids = self.options[:with_user_ids] || []
without_user_ids = self.options[:without_user_ids] || []
with_types = self.options[:with_types] || []
without_types = self.options[:without_types] || []

# Don't touch files belonging to users that have active CBRAIN tasks
act_tasks_user_ids = CbrainTask.active
.where(:bourreau_id => CBRAIN::SelfRemoteResourceId)
.group(:user_id).pluck(:user_id)
without_user_ids += act_tasks_user_ids

# Base scopes: files cached locally and having been access longer that days_older
scope = Userfile.all.joins(:sync_status)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
<%= red_if(bac.num_failures == 0, "Failed=#{bac.num_failures}", nil, :color1 => 'red', :color2 => 'black') %>
<% end %>
<% if current_user.has_role?(:admin_user) && bac.handler_lock.present? %>
<span class="warning">ACTIVE=<%= bac.handler_lock %></span>
| <span class="warning">LOCK=<%= bac.handler_lock %></span>
<% end %>
<% if messages.present? %>
<% messages = messages.map { |m| h(m) }.join("<br>").html_safe %>
Expand Down
11 changes: 11 additions & 0 deletions BrainPortal/app/views/noc/dashboard.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@
<div class="noc_count" style="color: <%= num_excep_color %>"><%= @num_exceptions %></div>
</div>
<% end %>

<% if @num_bacs_progress + @num_bacs_completed + @num_bacs_failed + @num_bacs_partial > 0 %>
<div class="noc_panel">
<div class="noc_header">Background Activities</div><br>
<div class="noc_count">
<% # Note: that very long line is to make sure no spaces are inserted anywhere within the div %>
<%= (@num_bacs_progress > 0).presence && html_colorize(@num_bacs_progress,'blue') %><%= (@num_bacs_completed > 0 && @num_bacs_progress > 0).presence && '/' %><%= (@num_bacs_completed > 0).presence && html_colorize(@num_bacs_completed,'green') %><%= (@num_bacs_partial > 0 && (@num_bacs_progress+@num_bacs_completed > 0)).presence && '/' %><%= (@num_bacs_partial > 0).presence && html_colorize(@num_bacs_partial,'yellow') %><%= (@num_bacs_failed > 0 && (@num_bacs_progress+@num_bacs_completed+@num_bacs_partial > 0)).presence && '/' %><%= (@num_bacs_failed > 0).presence && html_colorize(@num_bacs_failed,'red') %>
</div>
</div>
<% end %>
</div>
Expand Down

0 comments on commit 7fc5428

Please sign in to comment.