app/helpers/courses_helpers.rb
# helper method for printing json-formatted sections based on a sections collection and a list of section_ids
helper method for printing json-formatted sections based on a sections collection and a list of section_ids
helper method for printing json - formatted sections based on a sections collection and a list of section_ids
def find_sections db, semester, section_ids
        sections = (section_ids.map {|e| "'#{e}'"}).join ','
        res = db.exec("SELECT * FROM sections WHERE semester=#{semester} AND section_id in (#{sections})")
        if !res
          halt 404, {
            error_code: 404,
            message: "Section with section_id #{section_ids[0]} not found.",
            available_sections: "https://api.umd.io/v0/courses/sections",
            docs: "https://umd.io/courses"
          }.to_json
        end
        cleaned_rows = []
        res.each do |row|
          cleaned_rows << (clean_section db, semester, row)
        end
        return cleaned_rows
      end
def find_sections db , semester , section_ids sections = ( section_ids . map { | e | "'#{e}'" } ) . join ',' res = db . exec ( "SELECT * FROM sections WHERE semester=#{semester} AND section_id in (#{sections})" ) if ! res halt 404 , { error_code : 404 , message : "Section with section_id #{section_ids[0]} not found." , available_sections : "https://api.umd.io/v0/courses/sections" , docs : "https://umd.io/courses" } . to_json end cleaned_rows = [ ] res . each do | row | cleaned_rows << ( clean_section db , semester , row ) end return cleaned_rows end
helper method for printing json-formatted sections based on a sections collection and a list of section_ids
helper method for printing json - formatted sections based on a sections collection and a list of section_ids
# Turn section_ids into string # This is proably ok, because we know that semester and section_ids both match expected formats # TODO: Take another look here, for security purposes # Decode arrays and json
db
semester
section_ids