Commit 7c3b586b authored by Zac Wood's avatar Zac Wood

Show unique semesters

parent 9c15a71c
Pipeline #5003 passed with stages
in 26 minutes and 12 seconds
......@@ -4,11 +4,8 @@ class CoursesController < ApplicationController
@course = Course.find_by_id(params[:id])
@rating = @course.rating
semester_ids = @course.course_sections
.joins(:semester)
.select("semesters.id")
@semesters = Semester.where(id: semester_ids.map(&:id))
semester_ids = Set.new(@course.course_sections.map(&:semester_id)).to_a
@semesters = Semester.where(id: semester_ids)
@semesters = Semester.sorted_by_date(@semesters)
@taught_in = Set.new(@semesters.map(&:season))
......
......@@ -8,11 +8,9 @@ class InstructorsController < ApplicationController
# find the courses being taught this semester
sections = CourseSection.where(instructor: @instructor)
semester_ids = sections
.joins(:semester)
.select("semesters.id")
semester_ids = Set.new(sections.map(&:semester_id))
@semesters = Semester.where(id: semester_ids.map(&:id))
@semesters = Semester.where(id: semester_ids.to_a)
@semesters = Semester.sorted_by_date(@semesters)
@sections = sections.where(semester: @semester).group_by { |s| s.section_type }
......
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