2020-02-21 00:02:38 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Dashboard
|
|
|
|
class CalendarsController < ApplicationController
|
2020-02-26 00:19:11 +08:00
|
|
|
include IconsHelper
|
2020-05-08 17:56:29 +08:00
|
|
|
include MyModulesHelper
|
2020-02-26 00:19:11 +08:00
|
|
|
|
2020-02-21 00:02:38 +08:00
|
|
|
def show
|
2020-08-10 18:55:56 +08:00
|
|
|
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
|
2020-02-23 01:15:18 +08:00
|
|
|
due_dates = current_user.my_modules.active.uncomplete
|
2020-03-03 20:13:46 +08:00
|
|
|
.joins(experiment: :project)
|
2020-03-03 23:10:52 +08:00
|
|
|
.where(experiments: { archived: false })
|
|
|
|
.where(projects: { archived: false })
|
2020-03-03 20:13:46 +08:00
|
|
|
.where('my_modules.due_date > ? AND my_modules.due_date < ?', start_date, end_date)
|
2020-03-03 23:10:52 +08:00
|
|
|
.joins(:protocols).where(protocols: { team_id: current_team.id })
|
2020-02-23 01:15:18 +08:00
|
|
|
.pluck(:due_date)
|
2020-08-10 18:55:56 +08:00
|
|
|
render json: { events: due_dates.map { |i| { date: i.to_date } } }
|
2020-02-21 00:02:38 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def day
|
2020-08-10 18:55:56 +08:00
|
|
|
date = params[:date].in_time_zone(current_user.time_zone)
|
|
|
|
start_date = date.utc
|
|
|
|
end_date = date.end_of_day.utc
|
2020-02-23 01:15:18 +08:00
|
|
|
my_modules = current_user.my_modules.active.uncomplete
|
2020-03-03 20:13:46 +08:00
|
|
|
.joins(experiment: :project)
|
2020-03-03 23:10:52 +08:00
|
|
|
.where(experiments: { archived: false })
|
|
|
|
.where(projects: { archived: false })
|
2020-08-10 18:55:56 +08:00
|
|
|
.where('my_modules.due_date > ? AND my_modules.due_date < ?', start_date, end_date)
|
2020-03-03 23:10:52 +08:00
|
|
|
.where(projects: { team_id: current_team.id })
|
2020-02-21 00:02:38 +08:00
|
|
|
render json: {
|
2020-05-07 18:51:18 +08:00
|
|
|
html: render_to_string(partial: 'shared/my_modules_list_partial.html.erb', locals: {
|
2020-05-08 17:56:29 +08:00
|
|
|
my_modules: my_modules
|
2020-05-07 18:51:18 +08:00
|
|
|
})
|
2020-02-21 00:02:38 +08:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|