Skip to content

Instantly share code, notes, and snippets.

@trickydisco78
Last active November 8, 2018 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trickydisco78/13d4bd010782dfb22ccac45e1e947443 to your computer and use it in GitHub Desktop.
Save trickydisco78/13d4bd010782dfb22ccac45e1e947443 to your computer and use it in GitHub Desktop.
function buildSearchQuery(year,courseType,keyword) {
const searchOptions = {
undergraduate: `?query=${keyword}&sort=score&dir=desc&sort=UndergraduateCourse-programname&dir=asc&filter%3AUndergraduateCourse-year=${year}`,
postgraduate: `?query=${keyword}&sort=score&dir=desc&sort=PostgraduateCourse-programtype&dir=asc&sort=PostgraduateCourse-programname&dir=asc${year}`,
}
return searchOptions[courseType]
}
function buildURLPath(courseType) {
const courseUrl = {
undergraduate: `'/undergraduate/search/search_results/`,
postgraduate: `'/postgraduate/search/search_results/`,
};
return courseUrl[courseType]
}
function buildFullSearchURL (year, courseType, keyword) {
return buildURLPath(courseType) + buildSearchQuery(year,courseType,keyword)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment