mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-05 04:34:37 +08:00
Fix dashboard filters for tasks [SCI-12278]
This commit is contained in:
parent
d30e1a0a7b
commit
84f806f623
4 changed files with 15 additions and 18 deletions
|
@ -9,13 +9,13 @@ module Dashboard
|
|||
date = params[:date].to_date
|
||||
start_date = date.beginning_of_month - 8.days
|
||||
end_date = date.end_of_month + 15.days
|
||||
due_dates = current_user.my_modules.readable_by_user(current_user).active.uncomplete
|
||||
.joins(experiment: :project)
|
||||
.where(experiments: { archived: false })
|
||||
.where(projects: { archived: false })
|
||||
.where(my_modules: { due_date: start_date..end_date })
|
||||
.joins(:protocols).where(protocols: { team_id: current_team.id })
|
||||
.pluck(:due_date)
|
||||
due_dates = MyModule.readable_by_user(current_user).active.uncomplete
|
||||
.joins(experiment: :project)
|
||||
.where(experiments: { archived: false })
|
||||
.where(projects: { archived: false })
|
||||
.where(my_modules: { due_date: start_date..end_date })
|
||||
.joins(:protocols).where(protocols: { team_id: current_team.id })
|
||||
.pluck(:due_date)
|
||||
render json: { events: due_dates.map { |i| { date: i.to_date } } }
|
||||
end
|
||||
|
||||
|
@ -23,12 +23,12 @@ module Dashboard
|
|||
date = params[:date].to_date
|
||||
start_date = date.beginning_of_day
|
||||
end_date = date.end_of_day
|
||||
my_modules = current_user.my_modules.readable_by_user(current_user).active.uncomplete
|
||||
.joins(experiment: :project)
|
||||
.where(experiments: { archived: false })
|
||||
.where(projects: { archived: false })
|
||||
.where(my_modules: { due_date: start_date..end_date })
|
||||
.where(projects: { team_id: current_team.id })
|
||||
my_modules = MyModule.readable_by_user(current_user).active.uncomplete
|
||||
.joins(experiment: :project)
|
||||
.where(experiments: { archived: false })
|
||||
.where(projects: { archived: false })
|
||||
.where(my_modules: { due_date: start_date..end_date })
|
||||
.where(projects: { team_id: current_team.id })
|
||||
render json: {
|
||||
html: render_to_string(partial: 'shared/my_modules_list_partial',
|
||||
locals: { my_modules: my_modules },
|
||||
|
|
|
@ -34,7 +34,7 @@ module Dashboard
|
|||
.search_by_name(current_user, current_team, params[:query]).select(:id, :name)
|
||||
|
||||
unless params[:mode] == 'team'
|
||||
projects = projects.where(id: current_user.my_modules.joins(:experiment)
|
||||
projects = projects.where(id: MyModule.readable_by_user(current_user).joins(:experiment)
|
||||
.group(:project_id).select(:project_id).pluck(:project_id))
|
||||
end
|
||||
render json: projects.map { |i| { value: i.id, label: escape_input(i.name) } }, status: :ok
|
||||
|
@ -51,7 +51,7 @@ module Dashboard
|
|||
.search_by_name(current_user, current_team, params[:query]).select(:id, :name)
|
||||
|
||||
unless params[:mode] == 'team'
|
||||
experiments = experiments.where(id: current_user.my_modules
|
||||
experiments = experiments.where(id: MyModule.readable_by_user(current_user)
|
||||
.group(:experiment_id).select(:experiment_id).pluck(:experiment_id))
|
||||
end
|
||||
render json: experiments.map { |i| { value: i.id, label: escape_input(i.name) } }, status: :ok
|
||||
|
|
|
@ -62,9 +62,7 @@ class User < ApplicationRecord
|
|||
has_many :user_group_memberships, dependent: :destroy
|
||||
has_many :user_groups, through: :user_group_memberships
|
||||
has_many :teams, through: :user_assignments, source: :assignable, source_type: 'Team'
|
||||
has_many :projects, through: :user_assignments, source: :assignable, source_type: 'Project'
|
||||
has_many :user_my_modules, inverse_of: :user
|
||||
has_many :my_modules, through: :user_assignments, source: :assignable, source_type: 'MyModule'
|
||||
has_many :comments, inverse_of: :user
|
||||
has_many :activities, inverse_of: :owner, foreign_key: 'owner_id'
|
||||
has_many :results, inverse_of: :user
|
||||
|
|
|
@ -47,7 +47,6 @@ describe User, type: :model do
|
|||
|
||||
describe 'Relations' do
|
||||
it { should have_many :teams }
|
||||
it { should have_many :projects }
|
||||
it { should have_many :user_my_modules }
|
||||
it { should have_many :comments }
|
||||
it { should have_many :activities }
|
||||
|
|
Loading…
Add table
Reference in a new issue