Merge pull request #2781 from aignatov-bio/ai-sci-4919-fix-dashboard-calendar

Fix dashboard calendar due date selection [SCI-4919]
This commit is contained in:
aignatov-bio 2020-08-10 14:34:23 +02:00 committed by GitHub
commit 67b6592470
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,9 +6,9 @@ module Dashboard
include MyModulesHelper
def show
date = DateTime.parse(params[:date])
start_date = date.at_beginning_of_month.utc - 7.days
end_date = date.at_end_of_month.utc + 14.days
date = params[:date].in_time_zone(current_user.time_zone)
start_date = date.at_beginning_of_month.utc - 8.days
end_date = date.at_end_of_month.utc + 15.days
due_dates = current_user.my_modules.active.uncomplete
.joins(experiment: :project)
.where(experiments: { archived: false })
@ -16,16 +16,18 @@ module Dashboard
.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 } } }
render json: { events: due_dates.map { |i| { date: i.to_date } } }
end
def day
date = DateTime.parse(params[:date]).utc
date = params[:date].in_time_zone(current_user.time_zone)
start_date = date.utc
end_date = date.end_of_day.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('my_modules.due_date > ? AND 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.html.erb', locals: {