Skip to content

Commit 7fc5428

Browse files
committed
NOC for BACs; better CleanCache BAC.
1 parent 0a5dcf9 commit 7fc5428

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

BrainPortal/app/controllers/noc_controller.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,17 @@ def gather_info(since_when) #:nodoc:
309309
# Number of exceptions
310310
@num_exceptions = ExceptionLog.where([ "created_at > ?", since_when ]).count
311311
@num_exceptions = rand(fake) if fake
312+
313+
# Number of BackgroundActivities (non scheduled) updated
314+
bacs = BackgroundActivity
315+
.where(:status => [ 'InProgress', 'Completed', 'Failed', 'PartiallyCompleted' ])
316+
.where([ "updated_at > ?", since_when ])
317+
.group(:status).count
318+
@num_bacs_progress = bacs['InProgress'] || 0 # in blue
319+
@num_bacs_completed = bacs['Completed'] || 0 # in green
320+
@num_bacs_partial = bacs['PartiallyCompleted'] || 0 # in yellow
321+
@num_bacs_failed = bacs['Failed'] || 0 # in red
322+
312323
end
313324

314325
# Show IP address

BrainPortal/app/models/background_activity/clean_cache.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,16 @@ def process(item)
5757

5858
def prepare_dynamic_items
5959
days_older = self.options[:days_older] || DEFAULT_DAYS_OLD
60-
with_user_ids = self.options[:with_user_ids]
61-
without_user_ids = self.options[:without_user_ids]
62-
with_types = self.options[:with_types]
63-
without_types = self.options[:without_types]
60+
with_user_ids = self.options[:with_user_ids] || []
61+
without_user_ids = self.options[:without_user_ids] || []
62+
with_types = self.options[:with_types] || []
63+
without_types = self.options[:without_types] || []
64+
65+
# Don't touch files belonging to users that have active CBRAIN tasks
66+
act_tasks_user_ids = CbrainTask.active
67+
.where(:bourreau_id => CBRAIN::SelfRemoteResourceId)
68+
.group(:user_id).pluck(:user_id)
69+
without_user_ids += act_tasks_user_ids
6470

6571
# Base scopes: files cached locally and having been access longer that days_older
6672
scope = Userfile.all.joins(:sync_status)

BrainPortal/app/views/background_activities/_background_activity_table.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
<%= red_if(bac.num_failures == 0, "Failed=#{bac.num_failures}", nil, :color1 => 'red', :color2 => 'black') %>
198198
<% end %>
199199
<% if current_user.has_role?(:admin_user) && bac.handler_lock.present? %>
200-
<span class="warning">ACTIVE=<%= bac.handler_lock %></span>
200+
| <span class="warning">LOCK=<%= bac.handler_lock %></span>
201201
<% end %>
202202
<% if messages.present? %>
203203
<% messages = messages.map { |m| h(m) }.join("<br>").html_safe %>

BrainPortal/app/views/noc/dashboard.html.erb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@
9393
<div class="noc_count" style="color: <%= num_excep_color %>"><%= @num_exceptions %></div>
9494
</div>
9595
<% end %>
96+
97+
<% if @num_bacs_progress + @num_bacs_completed + @num_bacs_failed + @num_bacs_partial > 0 %>
98+
<div class="noc_panel">
99+
<div class="noc_header">Background Activities</div><br>
100+
<div class="noc_count">
101+
<% # Note: that very long line is to make sure no spaces are inserted anywhere within the div %>
102+
<%= (@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') %>
103+
</div>
104+
</div>
105+
<% end %>
106+
96107
</div>
97108
98109

0 commit comments

Comments
 (0)