Commit 9f011a08 authored by Zach Perkins's avatar Zach Perkins

Made the section count for instructors only count sections in the current semester

parent 9b0290a3
Pipeline #3220 failed with stage
in 2 minutes and 10 seconds
......@@ -29,9 +29,10 @@ module SearchHelper
end
def self.fetch_instructors(query_data)
Instructor.from_name(Instructor.select("instructors.*, COUNT(course_sections.id) AS section_count"), query_data.search_string)
.left_outer_joins(:course_sections)
.group("instructors.id")
Instructor.from_name(Instructor.select("instructors.*, COUNT(courses.id) AS section_count").from("course_sections"), query_data.search_string)
.joins("LEFT OUTER JOIN instructors ON instructors.id = course_sections.instructor_id")
.joins("LEFT OUTER JOIN courses ON courses.id = course_sections.course_id AND courses.semester_id = #{query_data.semester.id}")
.group("instructors.id").all
end
def self.fetch_courses(query_data)
......
......@@ -17,8 +17,8 @@
</div>
<div class="card-body">
<div class="attr-list">
<div class="attr"><i class="fa fa-book"></i> 3 credits</div>
<div class="attr"><i class="fa fa-bars"></i> 3 sections</div>
<div class="attr"><i class="fa fa-book"></i> 3 credits</div> <!-- TODO: Make this work -->
<div class="attr"><i class="fa fa-bars"></i> <%= "#{course.section_count}" %> sections</div>
</div>
<p class="description"><%= course.description %></p>
......
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