mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-02 13:12:13 +08:00
Merge pull request #2443 from aignatov-bio/ai-sci-4409-fix-visibilty-of-tasks
Fix task visibility for current task widget [SCI-4409]
This commit is contained in:
commit
30545f5cf4
3 changed files with 31 additions and 11 deletions
|
@ -9,8 +9,11 @@ module Dashboard
|
|||
start_date = date.at_beginning_of_month.utc - 7.days
|
||||
end_date = date.at_end_of_month.utc + 14.days
|
||||
due_dates = current_user.my_modules.active.uncomplete
|
||||
.where('due_date > ? AND due_date < ?', start_date, end_date)
|
||||
.joins(:protocols).where('protocols.team_id = ?', current_team.id)
|
||||
.joins(experiment: :project)
|
||||
.where(experiments: { archived: false })
|
||||
.where(projects: { archived: false })
|
||||
.where('my_modules.due_date > ? AND 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 } } }
|
||||
end
|
||||
|
@ -18,8 +21,11 @@ module Dashboard
|
|||
def day
|
||||
date = DateTime.parse(params[:date]).utc
|
||||
my_modules = current_user.my_modules.active.uncomplete
|
||||
.joins(experiment: :project)
|
||||
.where(experiments: { archived: false })
|
||||
.where(projects: { archived: false })
|
||||
.where('DATE(my_modules.due_date) = DATE(?)', date)
|
||||
.where('projects.team_id = ?', current_team.id)
|
||||
.where(projects: { team_id: current_team.id })
|
||||
.my_modules_list_partial
|
||||
render json: {
|
||||
html: render_to_string(partial: 'shared/my_modules_list_partial.html.erb', locals: { task_groups: my_modules })
|
||||
|
|
|
@ -12,14 +12,19 @@ module Dashboard
|
|||
tasks = if @experiment
|
||||
@experiment.my_modules.active
|
||||
elsif @project
|
||||
MyModule.active.joins(:experiment).where('experiments.project_id': @project.id)
|
||||
MyModule.active.where(projects: { id: @project.id })
|
||||
else
|
||||
MyModule.active.viewable_by_user(current_user, current_team)
|
||||
end
|
||||
|
||||
tasks = tasks.joins(experiment: :project)
|
||||
.where(experiments: { archived: false })
|
||||
.where(projects: { archived: false })
|
||||
|
||||
if task_filters[:mode] == 'assigned'
|
||||
tasks = tasks.left_outer_joins(:user_my_modules).where('user_my_modules.user_id': current_user.id)
|
||||
tasks = tasks.left_outer_joins(:user_my_modules).where(user_my_modules: { user_id: current_user.id })
|
||||
end
|
||||
tasks = tasks.where('my_modules.state': task_filters[:view])
|
||||
tasks = tasks.where(my_modules: { state: task_filters[:view] })
|
||||
.search_by_name(current_user, current_team, task_filters[:query])
|
||||
|
||||
case task_filters[:sort]
|
||||
|
@ -56,7 +61,11 @@ module Dashboard
|
|||
end
|
||||
|
||||
def project_filter
|
||||
projects = current_team.projects.search(current_user, false, params[:query], 1, current_team).select(:id, :name)
|
||||
projects = current_team.projects
|
||||
.where(archived: false)
|
||||
.viewable_by_user(current_user, current_team)
|
||||
.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)
|
||||
.group(:project_id).select(:project_id).pluck(:project_id))
|
||||
|
@ -69,7 +78,11 @@ module Dashboard
|
|||
render json: []
|
||||
return false
|
||||
end
|
||||
experiments = @project.experiments.search(current_user, false, params[:query], 1, current_team).select(:id, :name)
|
||||
experiments = @project.experiments
|
||||
.where(archived: false)
|
||||
.viewable_by_user(current_user, current_team)
|
||||
.search_by_name(current_user, current_team, params[:query]).select(:id, :name)
|
||||
|
||||
unless params[:mode] == 'team'
|
||||
experiments = experiments.where(id: current_user.my_modules
|
||||
.group(:experiment_id).select(:experiment_id).pluck(:experiment_id))
|
||||
|
|
|
@ -81,13 +81,14 @@ class MyModule < ApplicationRecord
|
|||
scope :workflow_ordered, -> { order(workflow_order: :asc) }
|
||||
scope :uncomplete, -> { where(state: 'uncompleted') }
|
||||
scope :with_step_statistics, (lambda do
|
||||
joins(protocols: :steps)
|
||||
left_outer_joins(protocols: :steps)
|
||||
.group(:id)
|
||||
.select('my_modules.*')
|
||||
.select('COUNT(steps.id) AS steps_total')
|
||||
.select('COUNT(steps.id) FILTER (where steps.completed = true) AS steps_completed')
|
||||
.select('((COUNT(steps.id) FILTER (where steps.completed = true)) * 100 / COUNT(steps.id)) '\
|
||||
'AS steps_completed_percentage')
|
||||
.select('CASE COUNT(steps.id) WHEN 0 THEN 0 ELSE'\
|
||||
'((COUNT(steps.id) FILTER (where steps.completed = true)) * 100 / COUNT(steps.id)) '\
|
||||
'END AS steps_completed_percentage')
|
||||
end)
|
||||
|
||||
# A module takes this much space in canvas (x, y) in database
|
||||
|
|
Loading…
Reference in a new issue