From cf2872d165f95c75d624faea04232ddf004c917e Mon Sep 17 00:00:00 2001 From: MontrealSergiy Date: Mon, 12 Aug 2024 14:28:38 -0400 Subject: [PATCH] Increase visibility of the full tool list link - optimization #1409 --- .../app/controllers/portal_controller.rb | 21 +++++++------------ BrainPortal/app/views/portal/welcome.html.erb | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/BrainPortal/app/controllers/portal_controller.rb b/BrainPortal/app/controllers/portal_controller.rb index 526837ddf..e02b0b1a3 100644 --- a/BrainPortal/app/controllers/portal_controller.rb +++ b/BrainPortal/app/controllers/portal_controller.rb @@ -46,19 +46,14 @@ def welcome #:nodoc: @default_data_provider = DataProvider.find_by_id(current_user.meta["pref_data_provider_id"]) @default_bourreau = Bourreau.find_by_id(current_user.meta["pref_bourreau_id"]) - @tools = Tool - .all - .order(:name) - .to_a - .reject { |t| t.category == 'background' } - .select { |t| t.tool_configs.to_a.any? { |tc| - tc.bourreau_id.present? && - tc.bourreau_id > 0 && - tc.version_name.present? - } - } - - @avaiable_tools = @tools + @tool_count = Tool + .joins(:tool_configs) + .where.not(category: 'background') + .where('tool_configs.bourreau_id IS NOT NULL') + .where('tool_configs.bourreau_id > 0') + .where('tool_configs.version_name IS NOT NULL') + .distinct + .count @dashboard_messages = Message .where(:message_type => 'cbrain_dashboard') diff --git a/BrainPortal/app/views/portal/welcome.html.erb b/BrainPortal/app/views/portal/welcome.html.erb index b7e545898..0df2ac6a6 100644 --- a/BrainPortal/app/views/portal/welcome.html.erb +++ b/BrainPortal/app/views/portal/welcome.html.erb @@ -167,7 +167,7 @@ Your current time: <%= to_localtime(Time.now, :datetime) %>

- Tools available to you ( out of <%= link_to @tools.count , available_path %> ) :
+ Tools available to you ( out of <%= link_to @tool_count , available_path %> ) :
<%= array_to_table(current_user.available_tools.where( "category <> 'background'" ).to_a.map(&:name).sort, :table_class => 'simple', :cols => 4) %>