Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
schedules
Commits
091006ce
Commit
091006ce
authored
Sep 13, 2018
by
Zach Perkins
Browse files
Fix spacin
parent
261b01a8
Pipeline
#2889
passed with stage
in 2 minutes and 23 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
schedules_api/app/controllers/course_listing_controller.rb
View file @
091006ce
...
...
@@ -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 sep
e
rate 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 sep
a
rate 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment