mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-02 19:22:09 +08:00
Improve performance of fetching of statuses [SCI-5062]
This commit is contained in:
parent
d02d48f10f
commit
134e549ed5
7 changed files with 19 additions and 8 deletions
|
|
@ -37,7 +37,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
# Sets current team for all controllers
|
||||
def current_team
|
||||
Team.find_by_id(current_user.current_team_id)
|
||||
@current_team ||= Team.find_by(id: current_user.current_team_id)
|
||||
end
|
||||
|
||||
def to_user_date_format
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DashboardsController < ApplicationController
|
||||
def show; end
|
||||
def show
|
||||
@my_module_status_flows = MyModuleStatusFlow.all.preload(my_module_statuses: :my_module_status_consequences)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ class MyModuleStatusFlowController < ApplicationController
|
|||
before_action :check_view_permissions
|
||||
|
||||
def show
|
||||
my_module_statuses = @my_module.my_module_status_flow.my_module_statuses.sort_by_position
|
||||
my_module_statuses = @my_module.my_module_status_flow
|
||||
.my_module_statuses
|
||||
.preload(:my_module_status_implications, next_status: :my_module_status_conditions)
|
||||
.sort_by_position
|
||||
render json: { html: render_to_string(partial: 'my_modules/modals/status_flow_modal_body.html.erb',
|
||||
locals: { my_module_statuses: my_module_statuses }) }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@ Canaid::Permissions.register_for(Experiment) do
|
|||
# assign/reassign/unassign tags
|
||||
can :manage_experiment do |user, experiment|
|
||||
user.is_user_or_higher_of_project?(experiment.project) &&
|
||||
MyModule.joins(:experiment).where(experiment: experiment).all? do |my_module|
|
||||
MyModule.joins(:experiment)
|
||||
.where(experiment: experiment)
|
||||
.preload(my_module_status: :my_module_status_implications)
|
||||
.all? do |my_module|
|
||||
if my_module.my_module_status
|
||||
my_module.my_module_status.my_module_status_implications.all? { |implication| implication.call(my_module) }
|
||||
else
|
||||
|
|
|
|||
|
|
@ -38,7 +38,10 @@ Canaid::Permissions.register_for(Project) do
|
|||
# project: update/delete, assign/reassign/unassign users
|
||||
can :manage_project do |user, project|
|
||||
user.is_owner_of_project?(project) &&
|
||||
MyModule.joins(experiment: :project).where(experiments: { project: project }).all? do |my_module|
|
||||
MyModule.joins(experiment: :project)
|
||||
.where(experiments: { project: project })
|
||||
.preload(my_module_status: :my_module_status_implications)
|
||||
.all? do |my_module|
|
||||
if my_module.my_module_status
|
||||
my_module.my_module_status.my_module_status_implications.all? { |implication| implication.call(my_module) }
|
||||
else
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@
|
|||
data-select-multiple-name="<%= t("dashboard.current_tasks.filter.statuses.selected") %>"
|
||||
multiple
|
||||
>
|
||||
<% MyModuleStatusFlow.find_each do |status_flow| %>
|
||||
<% @my_module_status_flows.each do |status_flow| %>
|
||||
<% status_flow.my_module_statuses.each do |status| %>
|
||||
<option value="<%= status.id %>"
|
||||
data-completion-consequence="<%= status.my_module_status_consequences.where(type: "MyModuleStatusConsequences::Completion").any? %>">
|
||||
data-completion-consequence="<%= status.my_module_status_consequences.any? { |c| c.type == 'MyModuleStatusConsequences::Completion'} %>">
|
||||
<%= status.name %>
|
||||
</option>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<% if project.active_experiments.present? %>
|
||||
<ul class="tree-child hidden" data-branch-id="pro<%= project.id %>">
|
||||
<% project.sorted_active_experiments('atoz').each do |experiment| %>
|
||||
<% project.sorted_active_experiments('atoz').preload(:active_my_modules).each do |experiment| %>
|
||||
<% cache [action_name, current_user, experiment] do %>
|
||||
<li data-parent="candidate" class="branch">
|
||||
<span class="tree-link first-indent" title="<%= experiment.name %>">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue