Commit 8aa9f498 authored by Zach Perkins's avatar Zach Perkins
Browse files

Started work on basic filterint

parent 512d3abf
......@@ -8,6 +8,7 @@ class CourseSectionsController < ApplicationController
api :GET, '/courses_sections', 'Get a list of course sections'
param :course_id, Integer, desc: "Only get the course sections belonging to the course with this ID"
param :crn, String, desc: "Get the course section with this CRN"
param :query, String, desc: 'A generic query ex. "CS 110"'
def index
@sections = CourseSection.all
......@@ -16,4 +16,18 @@ class Course < ApplicationRecord
def course_sections
CourseSection.where course_id: id
def fetch(filters)
query ="*")
filters.each do |filter, value|
if Course.column_names.include? filter
case filter
when :subject
query.where("subject = ?", value)
when :course_number
query.where("course_number = ?", value)
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