app/helpers/courses_helpers.rb
def find_sections_for_course db, semester, course_id, expand
        sections = []

        if expand
          res = db.exec("SELECT * FROM sections WHERE semester=#{semester} AND course_id='#{course_id}'")
          res.each do |row|
            sections << (clean_section db, semester, row)
          end
        else
          res = db.exec("SELECT section_id FROM sections WHERE semester=#{semester} AND course_id='#{course_id}'")
          sections = res.values.flatten
        end

        return sections
      end
# generalize logic for checking if semester param valid
generalize logic for checking if semester param valid
generalize logic for checking if semester param valid
def find_sections_for_course db, semester, course_id, expand
        sections = []
        if expand
          res = db.exec("SELECT * FROM sections WHERE semester=#{semester} AND course_id='#{course_id}'")
          res.each do |row|
            sections << (clean_section db, semester, row)
          end
        else
          res = db.exec("SELECT section_id FROM sections WHERE semester=#{semester} AND course_id='#{course_id}'")
          sections = res.values.flatten
        end
        return sections
      end
def find_sections_for_course db , semester , course_id , expand sections = [ ] if expand res = db . exec ( "SELECT * FROM sections WHERE semester=#{semester} AND course_id='#{course_id}'" ) res . each do | row | sections << ( clean_section db , semester , row ) end else res = db . exec ( "SELECT section_id FROM sections WHERE semester=#{semester} AND course_id='#{course_id}'" ) sections = res . values . flatten end return sections end
generalize logic for checking if semester param valid
generalize logic for checking if semester param valid
db
semester
course_id
expand