Commit 091006ce authored by Zach Perkins's avatar Zach Perkins
Browse files

Fix spacin

parent 261b01a8
Pipeline #2889 passed with stage
in 2 minutes and 23 seconds
......@@ -2,26 +2,26 @@ class CourseListingController < ApplicationController
resource_description do
short 'Working with courses and associated sections'
end
api :GET, '/course_listing', "Get all available courses and their sections"
param :subject, String, desc:'Course subject, e.g. "CS" or "ACCT"'
param :subject, String, desc: 'Course subject, e.g. "CS" or "ACCT"'
param :number, Integer, desc: 'Course number, e.g. "112"'
def index
db_params = {}
# Grab all of the params we pass to the query from the GET arguments
params.each do |name, value|
db_params[name.to_sym] = value if Course.column_names.include? name
end
# Make a seperate list so that we can include sections
@courses = []
Course.where(db_params).all.each do |course_obj|
course = course_obj.attributes.dup
course[:sections] = course_obj.course_sections
@courses.push(course)
end
render json: @courses
db_params = {}
# Grab all of the params we pass to the query from the GET arguments
params.each do |name, value|
db_params[name.to_sym] = value if Course.column_names.include? name
end
# Make a separate list so that we can include sections
@courses = []
Course.where(db_params).all.each do |course_obj|
course = course_obj.attributes.dup
course[:sections] = course_obj.course_sections
@courses.push(course)
end
render json: @courses
end
end
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