Commit ae0d01c6 authored by Jiri Strojil's avatar Jiri Strojil

Excluded inactive missions from review form

parent ab302668
Pipeline #32958 failed with stage
in 34 minutes and 43 seconds
......@@ -15,7 +15,7 @@ class SemesterProcessVolunteer < ApplicationRecord
belongs_to :commited_by, -> { with_deleted }, class_name: 'User',
inverse_of: 'semester_processes', optional: true
has_many :semester_process_volunteer_missions, dependent: :destroy
has_many :semester_process_volunteer_missions, -> { active_missions }, dependent: :destroy
has_many :assignments, through: :semester_process_volunteer_missions
has_many :group_assignments, through: :semester_process_volunteer_missions
......
......@@ -3,4 +3,14 @@ class SemesterProcessVolunteerMission < ApplicationRecord
delegate :volunteer, to: :semester_process_volunteer
belongs_to :semester_process_volunteer
scope :active_missions, lambda {
joins(semester_process_volunteer: [:semester_process]).includes(:assignment, :group_assignment)
.where("semester_process_volunteer_missions.assignment_id IS NOT NULL AND
(assignments.period_end IS NULL OR assignments.period_end >= lower(semester_processes.semester))
OR
semester_process_volunteer_missions.group_assignment_id IS NOT NULL AND
(group_assignments.period_end is NULL OR group_assignments.period_end >= lower(semester_processes.semester))")
.references(:assignments, :group_assignments)
}
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment