Commit 4def498c authored by Chrysanthi Lagodimou's avatar Chrysanthi Lagodimou

Reduce number of queries for create journals

parent 5f878404
Pipeline #32541 passed with stage
in 55 minutes and 22 seconds
...@@ -30,11 +30,12 @@ module SemesterProcessVolunteerHelper ...@@ -30,11 +30,12 @@ module SemesterProcessVolunteerHelper
end end
def create_journals def create_journals
return unless SemesterProcessVolunteer.find(params[:id]).commited_at? spv = SemesterProcessVolunteer.find(params[:id])
volunteer = SemesterProcessVolunteer.find(params[:id]).volunteer return unless spv.commited_at?
semester_feedbacks = SemesterProcessVolunteer.find(params[:id]).semester_feedbacks volunteer = spv.volunteer
Journal.create(user: volunteer.user, journalable_id:, semester_feedbacks = spv.semester_feedbacks
journalable_type: 'Volunteer', category: :feedback, title: "Semester Prozess Feedback vom #{I18n.l(}: ", Journal.create(user: volunteer.user, journalable: volunteer,
category: :feedback, title: "Semester Prozess Feedback vom #{I18n.l(}: ",
body: render_semester_feedbacks(semester_feedbacks)) body: render_semester_feedbacks(semester_feedbacks))
end end
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment