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
...@@ -25,11 +25,11 @@ class SchedulesController < ApplicationController ...@@ -25,11 +25,11 @@ class SchedulesController < ApplicationController
"S": Date.new(2019, 1, 19), "S": Date.new(2019, 1, 19),
"U": Date.new(2019, 1, 20) "U": Date.new(2019, 1, 20)
}.freeze }.freeze
def show def show
@events = @cart.map do |_cid, sections| @events = @cart.map do |_cid, sections|
s = sections.first s = sections.first
s.days.split('').map do |day| s.days.split('').map do |day|
formatted_date = DAYS[day.to_sym].to_s.tr('-', '') formatted_date = DAYS[day.to_sym].to_s.tr('-', '')
time = Time.parse(s.start_time).strftime("%H%M%S") time = Time.parse(s.start_time).strftime("%H%M%S")
...@@ -41,7 +41,6 @@ class SchedulesController < ApplicationController ...@@ -41,7 +41,6 @@ class SchedulesController < ApplicationController
end: "#{formatted_date}T#{endtime}" end: "#{formatted_date}T#{endtime}"
} }
end end
end.flatten end.flatten
end end
end end
...@@ -29,9 +29,10 @@ module SearchHelper ...@@ -29,9 +29,10 @@ module SearchHelper
end end
def self.fetch_instructors(query_data) def self.fetch_instructors(query_data)
Instructor.from_name(Instructor.select("instructors.*, COUNT(course_sections.id) AS section_count"), query_data.search_string) Instructor.from_name(Instructor.select("instructors.*, COUNT(courses.id) AS section_count").from("course_sections"), query_data.search_string)
.left_outer_joins(:course_sections) .joins("LEFT OUTER JOIN instructors ON instructors.id = course_sections.instructor_id")
.group("instructors.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 end
def self.fetch_courses(query_data) def self.fetch_courses(query_data)
......
...@@ -13,9 +13,9 @@ class CourseSection < ApplicationRecord ...@@ -13,9 +13,9 @@ class CourseSection < ApplicationRecord
def labs def labs
return nil unless section_type == "Lecture" 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| 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
end end
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="attr-list"> <div class="attr-list">
<div class="attr"><i class="fa fa-book"></i> 3 credits</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> 3 sections</div> <div class="attr"><i class="fa fa-bars"></i> <%= "#{course.section_count}" %> sections</div>
</div> </div>
<p class="description"><%= course.description %></p> <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