Commit 13b59eec authored by Jiri Strojil's avatar Jiri Strojil 💬

Merge branch 'fixes/exclude-inactive-missions-in-review' into 'develop'

Excluded inactive missions from review form

See merge request !902
parents ab302668 c4f590e2
Pipeline #33009 passed with stage
in 42 minutes and 39 seconds
......@@ -37,11 +37,11 @@ class SemesterProcessVolunteer < ApplicationRecord
scope :active_missions, lambda {
joins(:semester_process_volunteer_missions).includes(semester_process_volunteer_missions: [: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))
.where("(semester_process_volunteer_missions.assignment_id IS NOT NULL AND
assignments.period_end IS NULL)
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))")
(semester_process_volunteer_missions.group_assignment_id IS NOT NULL AND
group_assignments.period_end is NULL)")
.references(:assignments, :group_assignments)
}
......@@ -71,8 +71,10 @@ class SemesterProcessVolunteer < ApplicationRecord
end
def build_missions(semester)
new_missions = volunteer.assignments.active_between(semester.begin, semester.end) +
volunteer.group_assignments.active_between(semester.begin, semester.end)
# if you change this then also change it within active_semester_mission(semester)
prob = semester.end.advance(weeks: -4)
new_missions = volunteer.assignments.no_end.start_before(prob) +
volunteer.group_assignments.no_end.start_before(prob)
semester_process_volunteer_missions << new_missions.map do |mission|
SemesterProcessVolunteerMission.new(mission: mission)
......
......@@ -3,4 +3,14 @@ class SemesterProcessVolunteerMission < ApplicationRecord
delegate :volunteer, to: :semester_process_volunteer
belongs_to :semester_process_volunteer
scope :need_feedback, lambda {
includes(:assignment, :group_assignment)
.where("(semester_process_volunteer_missions.assignment_id IS NOT NULL AND
assignments.period_end IS NULL)
OR
(semester_process_volunteer_missions.group_assignment_id IS NOT NULL AND
group_assignments.period_end is NULL)")
.references(:assignments, :group_assignments)
}
end
......@@ -244,10 +244,9 @@ class Volunteer < ApplicationRecord
def self.active_semester_mission(semester)
volunteers = Volunteer.have_mission
prob = semester.end.advance(weeks: -4)
sem_start = semester.begin
vol_with_missions = volunteers.select do |v|
[v.assignments, v.group_assignments].detect do |mission|
mission.where("period_start < ?", prob).where("period_end > ? OR period_end IS NULL", sem_start).any?
mission.where("period_end IS NULL").where("period_start < ?", prob).any?
end
end
vol_with_missions
......
......@@ -8,7 +8,7 @@
.col-xs-12
p.text-danger Bestätigt am #{l(@semester_process_volunteer.commited_at.to_date)} durch #{profile_link(@semester_process_volunteer.commited_by)}
= f.simple_fields_for :semester_feedbacks, @semester_process_volunteer.semester_process_volunteer_missions do |spvm|
= f.simple_fields_for :semester_feedbacks, @semester_process_volunteer.semester_process_volunteer_missions.need_feedback do |spvm|
- mission = spvm.object.mission
h2.m-b-20.m-t-30 Einsatz #{mission.to_label}
......
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