Commit e0f73f5a authored by Zac Wood's avatar Zac Wood

Merge branch 'hotfix-instructor-section-count' into 'dev-v2'

Hotfix instructor section count

See merge request !34
parents 9b0290a3 ede77540
Pipeline #3222 passed with stage
in 2 minutes and 11 seconds
......@@ -41,7 +41,6 @@ class SchedulesController < ApplicationController
end: "#{formatted_date}T#{endtime}"
}
end
end.flatten
end
end
......@@ -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)
......
......@@ -13,9 +13,9 @@ class CourseSection < ApplicationRecord
def labs
return nil unless section_type == "Lecture"
lecture_number = name.split[name.split.length-1]
lecture_number = name.split[name.split.length - 1]
course.course_sections.select do |s|
s.title.split[s.title.split.length-1] == lecture_number
s.title.split[s.title.split.length - 1] == lecture_number
end
end
......
......@@ -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