Commit f4a25fe6 authored by Zach Perkins's avatar Zach Perkins
Browse files

I hate rubocop with a burning passion

parent da99de12
# Replaces various strings with other strings when needed
# Replaces various strings with other strings when needed
module CourseReplacementHelper
@@replacements = {
"BIO"=> "BIOL",
"HONORS"=>"_HONORS_", # Sometimes the honors will be in parenthesis so this accounts for that
"ACADEMIC ENGLISH"=> "AE",
"ACCOUNTING"=> "ACCT",
"AFRICAN AND AFRICAN AMERICAN STUDIES"=> "AFAM",
"ANTHROPOLOGY"=> "ANTH",
"APPLIED INFORMATION TECHNOLOGY"=> "AIT",
"ARABIC"=> "ARAB",
"ART AND VISUAL TECHNOLOGY"=> "AVT",
"ART HISTORY"=> "ARTH",
"ARTS MANAGEMENT"=> "AMGT",
"ASSISTIVE TECHNOLOGY"=> "EDAT",
"ASTRONOMY"=> "ASTR",
"ATHLETIC TRAINING EDUCATION PROGRAM"=> "ATEP",
"BACHELOR OF INDIVIDUALIZED STUDY"=> "BIS",
"BACHELOR'S OF APPLIED SCIENCE"=> "BAS",
"BIODEFENSE"=> "BIOD",
"BIOENGINEERING"=> "BENG",
"BIOINFORMATICS"=> "BINF",
"BIOLOGY"=> "BIOL",
"BIOMEDICAL SCIENCES"=> "BMED",
"BIOSCIENCES"=> "BIOS",
"BUSINESS AND LEGAL STUDIES"=> "BULE",
"BUSINESS"=> "BUS",
"BUSINESS MANAGEMENT"=> "BMGT",
"BUSINESS MANAGEMENT OF SECURE INFORMATION SYSTEMS"=> "MSIS",
"CHEMISTRY"=> "CHEM",
"CHINESE"=> "CHIN",
"CIVIL AND INFRASTRUCTURE ENGINEERING"=> "CEIE",
"CLASSICS"=> "CLAS",
"CLIMATE DYNAMICS"=> "CLIM",
"COLLEGE OF SCIENCE"=> "COS",
"COLLEGE OF VISUAL AND PERFORMING ARTS"=> "CVPA",
"COMMUNICATION"=> "COMM",
"COMPUTATIONAL AND DATA SCIENCES"=> "CDS",
"COMPUTATIONAL SCIENCE AND INFORMATICS"=> "CSI",
"COMPUTATIONAL SOCIAL SCIENCE"=> "CSS",
"COMPUTER FORENSICS"=> "CFRS",
"COMPUTER GAME DESIGN"=> "GAME",
"COMPUTER SCIENCE"=> "CS",
"COMP SCI"=> "CS",
"CONFLICT ANALYSIS AND RESOLUTION"=> "CONF",
"CONSERVATION STUDIES"=> "CONS",
"COUNSELING AND DEVELOPMENT"=> "EDCD",
"CRIMINOLOGY"=> "CRIM",
"CULTURAL STUDIES"=> "CULT",
"CURRICULUM AND INSTRUCTION"=> "EDCI",
"CYBER SECURITY ENGINEERING"=> "CYSE",
"DANCE"=> "DANC",
"DATA ANALYTICS ENGINEERING"=> "DAEN",
"EARLY CHILDHOOD EDUCATION"=> "ECED",
"ECONOMICS"=> "ECON",
"EDUCATIONAL PSYCHOLOGY"=> "EDEP",
"EDUCATION"=> "EDUC",
"EDUCATION INSTRUCTIONAL TECHNOLOGY"=> "EDIT",
"EDUCATION LEADERSHIP"=> "EDLE",
"EDUCATION RESEARCH"=> "EDRS",
"ELECTRICAL AND COMPUTER ENGINEERING"=> "ECE",
"ENGINEERING"=> "ENGR",
"ENGLISH"=> "ENGH",
"ENGLISH FOR ACADEMIC PURPOSES"=> "EAP",
"ENVIRONMENTAL SCIENCE AND POLICY"=> "EVPP",
"EXECUTIVE MBA"=> "EMBA",
"EXERCISE, FITNESS, AND HEALTH PROMOTION"=> "EFHP",
"FILM AND VIDEO STUDIES"=> "FAVS",
"FINANCE"=> "FNAN",
"FOREIGN LANGUAGE"=> "FRLN",
"FORENSIC SCIENCE"=> "FRSC",
"FRENCH"=> "FREN",
"GEOGRAPHY AND GEOINFORMATION SCIENCE"=> "GGS",
"GEOLOGY"=> "GEOL",
"GERMAN"=> "GERM",
"GLOBAL AFFAIRS"=> "GLOA",
"GLOBAL AND COMMUNITY HEALTH"=> "GCH",
"GOVERNMENT"=> "GOVT",
"GRADUATE SCHOOL OF BUSINESS"=> "GBUS",
"GREEK"=> "GREE",
"HEALTH ADMINISTRATION AND POLICY"=> "HAP",
"HEALTH AND HUMAN SERVICES"=> "HHS",
"HEALTH"=> "HEAL",
"HEBREW"=> "HEBR",
"HIGHER EDUCATION"=> "HE",
"HISTORY"=> "HIST",
"HONORS COLLEGE"=> "HNRS",
"HUMAN DEVELOPMENT AND FAMILY SCIENCE"=> "HDFS",
"INFORMATION SECURITY ASSURANCE"=> "ISA",
"INFORMATION SYSTEMS"=> "INFS",
"INFORMATION TECHNOLOGY"=> "IT",
"INITIATIVES IN EDUCATIONAL TRANSFORMATION-TEACHING"=> "IETT",
"INTEGRATIVE STUDIES"=> "INTS",
"INTERDISCIPLINARY STUDIES"=> "MAIS",
"INTERNATIONAL COMMERCE AND POLICY"=> "ITRN",
"INTERNATIONAL YEAR ONE"=> "INYO",
"ITALIAN"=> "ITAL",
"JAPANESE"=> "JAPA",
"KINESIOLOGY"=> "KINE",
"KOREAN"=> "KORE",
"LATIN AMERICAN STUDIES"=> "LAS",
"LATIN"=> "LATN",
"LINGUISTICS"=> "LING",
"MANAGEMENT"=> "MGMT",
"MANAGEMENT OF INFORMATION SYSTEMS"=> "MIS",
"MANAGEMENT OF SECURE INFORMATION SYSTEMS"=> "MSEC",
"MARKETING"=> "MKTG",
"MATHEMATICS"=> "MATH",
"MECHANICAL ENGINEERING"=> "ME",
"MEDICAL LABORATORY SCIENCE"=> "MLAB",
"MIDDLE EAST AND ISLAMIC STUDIES"=> "MEIS",
"MILITARY SCIENCE"=> "MLSC",
"MINOR IN BUSINESS"=> "MBUS",
"MUSIC"=> "MUSI",
"NANOTECHNOLOGY AND NANOSCIENCE"=> "NANO",
"NATIVE AMERICAN AND INDIGENOUS STUDIES"=> "NAIS",
"NEUROSCIENCE"=> "NEUR",
"NURSING"=> "NURS",
"NUTRITION AND FOOD STUDIES"=> "NUTR",
"OPERATIONS MANAGEMENT"=> "OM",
"OPERATIONS RESEARCH"=> "OR",
"ORGANIZATION DEVELOPMENT AND KNOWLEDGE MANAGEMENT"=> "ODKM",
"PARKS, RECREATION, AND LEISURE STUDIES"=> "PRLS",
"PERSIAN"=> "PERS",
"PHILOSOPHY"=> "PHIL",
"PHYSICAL EDUCATION"=> "PHED",
"PHYSICS"=> "PHYS",
"POLICY AND GOVERNMENT"=> "POGO",
"PORTUGUESE"=> "PORT",
"PROFESSIONAL DEVELOPMENT IN EDUCATION"=> "EDPD",
"PROVOST"=> "PROV",
"PSYCHOLOGY"=> "PSYC",
"PUBLIC ADMINISTRATION"=> "PUAD",
"PUBLIC POLICY"=> "PUBP",
"READING"=> "EDRD",
"REAL ESTATE DEVELOPMENT"=> "REAL",
"RECREATION"=> "RECR",
"REHABILITATION SCIENCE"=> "RHBS",
"RELIGIOUS STUDIES"=> "RELI",
"RUSSIAN"=> "RUSS",
"SCHOOL OF MANAGEMENT"=> "SOM",
"SCHOOL PSYCHOLOGY"=> "SPSY",
"SOCIAL WORK"=> "SOCW",
"SOCIOLOGY AND ANTHROPOLOGY"=> "SOAN",
"SOCIOLOGY"=> "SOCI",
"SOFTWARE ENGINEERING"=> "SWE",
"SPANISH"=> "SPAN",
"SPECIAL EDUCATION"=> "EDSE",
"SPORT MANAGEMENT"=> "SPMT",
"SPORTS AND RECREATION STUDIES"=> "SRST",
"STATISTICS"=> "STAT",
"SYSTEM ENGINEERING"=> "SYST",
"SYSTEMS ENGINEERING AND OPERATIONS RESEARCH"=> "SEOR",
"TECHNOLOGY MANAGEMENT"=> "TECM",
"TELECOMMUNICATIONS"=> "TCOM",
"THEATER"=> "THR",
"TOURISM AND EVENTS MANAGEMENT"=> "TOUR",
"TURKISH"=> "TURK",
"UNIVERSITY STUDIES"=> "UNIV",
"URBAN AND SUBURBAN STUDIES"=> "USST",
"VOLGENAU SCHOOL OF ENGINEERING"=> "VSE",
"WOMEN AND GENDER STUDIES"=> "WMS",
"1"=> "I",
"2"=> "II",
"3"=> "III",
"4"=> "IV",
"5"=> "V"
@replacements = {
"BIO" => "BIOL",
"HONORS" => "_HONORS_", # Sometimes the honors will be in parenthesis so this accounts for that -> lol no it doesn't jk this needs fixed
"ACADEMIC ENGLISH" => "AE",
"ACCOUNTING" => "ACCT",
"AFRICAN AND AFRICAN AMERICAN STUDIES" => "AFAM",
"ANTHROPOLOGY" => "ANTH",
"APPLIED INFORMATION TECHNOLOGY" => "AIT",
"ARABIC" => "ARAB",
"ART AND VISUAL TECHNOLOGY" => "AVT",
"ART HISTORY" => "ARTH",
"ARTS MANAGEMENT" => "AMGT",
"ASSISTIVE TECHNOLOGY" => "EDAT",
"ASTRONOMY" => "ASTR",
"ATHLETIC TRAINING EDUCATION PROGRAM" => "ATEP",
"BACHELOR OF INDIVIDUALIZED STUDY" => "BIS",
"BACHELOR'S OF APPLIED SCIENCE" => "BAS",
"BIODEFENSE" => "BIOD",
"BIOENGINEERING" => "BENG",
"BIOINFORMATICS" => "BINF",
"BIOLOGY" => "BIOL",
"BIOMEDICAL SCIENCES" => "BMED",
"BIOSCIENCES" => "BIOS",
"BUSINESS AND LEGAL STUDIES" => "BULE",
"BUSINESS" => "BUS",
"BUSINESS MANAGEMENT" => "BMGT",
"BUSINESS MANAGEMENT OF SECURE INFORMATION SYSTEMS" => "MSIS",
"CHEMISTRY" => "CHEM",
"CHINESE" => "CHIN",
"CIVIL AND INFRASTRUCTURE ENGINEERING" => "CEIE",
"CLASSICS" => "CLAS",
"CLIMATE DYNAMICS" => "CLIM",
"COLLEGE OF SCIENCE" => "COS",
"COLLEGE OF VISUAL AND PERFORMING ARTS" => "CVPA",
"COMMUNICATION" => "COMM",
"COMPUTATIONAL AND DATA SCIENCES" => "CDS",
"COMPUTATIONAL SCIENCE AND INFORMATICS" => "CSI",
"COMPUTATIONAL SOCIAL SCIENCE" => "CSS",
"COMPUTER FORENSICS" => "CFRS",
"COMPUTER GAME DESIGN" => "GAME",
"COMPUTER SCIENCE" => "CS",
"COMP SCI" => "CS",
"CONFLICT ANALYSIS AND RESOLUTION" => "CONF",
"CONSERVATION STUDIES" => "CONS",
"COUNSELING AND DEVELOPMENT" => "EDCD",
"CRIMINOLOGY" => "CRIM",
"CULTURAL STUDIES" => "CULT",
"CURRICULUM AND INSTRUCTION" => "EDCI",
"CYBER SECURITY ENGINEERING" => "CYSE",
"DANCE" => "DANC",
"DATA ANALYTICS ENGINEERING" => "DAEN",
"EARLY CHILDHOOD EDUCATION" => "ECED",
"ECONOMICS" => "ECON",
"EDUCATIONAL PSYCHOLOGY" => "EDEP",
"EDUCATION" => "EDUC",
"EDUCATION INSTRUCTIONAL TECHNOLOGY" => "EDIT",
"EDUCATION LEADERSHIP" => "EDLE",
"EDUCATION RESEARCH" => "EDRS",
"ELECTRICAL AND COMPUTER ENGINEERING" => "ECE",
"ENGINEERING" => "ENGR",
"ENGLISH" => "ENGH",
"ENGLISH FOR ACADEMIC PURPOSES" => "EAP",
"ENVIRONMENTAL SCIENCE AND POLICY" => "EVPP",
"EXECUTIVE MBA" => "EMBA",
"EXERCISE, FITNESS, AND HEALTH PROMOTION" => "EFHP",
"FILM AND VIDEO STUDIES" => "FAVS",
"FINANCE" => "FNAN",
"FOREIGN LANGUAGE" => "FRLN",
"FORENSIC SCIENCE" => "FRSC",
"FRENCH" => "FREN",
"GEOGRAPHY AND GEOINFORMATION SCIENCE" => "GGS",
"GEOLOGY" => "GEOL",
"GERMAN" => "GERM",
"GLOBAL AFFAIRS" => "GLOA",
"GLOBAL AND COMMUNITY HEALTH" => "GCH",
"GOVERNMENT" => "GOVT",
"GRADUATE SCHOOL OF BUSINESS" => "GBUS",
"GREEK" => "GREE",
"HEALTH ADMINISTRATION AND POLICY" => "HAP",
"HEALTH AND HUMAN SERVICES" => "HHS",
"HEALTH" => "HEAL",
"HEBREW" => "HEBR",
"HIGHER EDUCATION" => "HE",
"HISTORY" => "HIST",
"HONORS COLLEGE" => "HNRS",
"HUMAN DEVELOPMENT AND FAMILY SCIENCE" => "HDFS",
"INFORMATION SECURITY ASSURANCE" => "ISA",
"INFORMATION SYSTEMS" => "INFS",
"INFORMATION TECHNOLOGY" => "IT",
"INITIATIVES IN EDUCATIONAL TRANSFORMATION-TEACHING" => "IETT",
"INTEGRATIVE STUDIES" => "INTS",
"INTERDISCIPLINARY STUDIES" => "MAIS",
"INTERNATIONAL COMMERCE AND POLICY" => "ITRN",
"INTERNATIONAL YEAR ONE" => "INYO",
"ITALIAN" => "ITAL",
"JAPANESE" => "JAPA",
"KINESIOLOGY" => "KINE",
"KOREAN" => "KORE",
"LATIN AMERICAN STUDIES" => "LAS",
"LATIN" => "LATN",
"LINGUISTICS" => "LING",
"MANAGEMENT" => "MGMT",
"MANAGEMENT OF INFORMATION SYSTEMS" => "MIS",
"MANAGEMENT OF SECURE INFORMATION SYSTEMS" => "MSEC",
"MARKETING" => "MKTG",
"MATHEMATICS" => "MATH",
"MECHANICAL ENGINEERING" => "ME",
"MEDICAL LABORATORY SCIENCE" => "MLAB",
"MIDDLE EAST AND ISLAMIC STUDIES" => "MEIS",
"MILITARY SCIENCE" => "MLSC",
"MINOR IN BUSINESS" => "MBUS",
"MUSIC" => "MUSI",
"NANOTECHNOLOGY AND NANOSCIENCE" => "NANO",
"NATIVE AMERICAN AND INDIGENOUS STUDIES" => "NAIS",
"NEUROSCIENCE" => "NEUR",
"NURSING" => "NURS",
"NUTRITION AND FOOD STUDIES" => "NUTR",
"OPERATIONS MANAGEMENT" => "OM",
"OPERATIONS RESEARCH" => "OR",
"ORGANIZATION DEVELOPMENT AND KNOWLEDGE MANAGEMENT" => "ODKM",
"PARKS, RECREATION, AND LEISURE STUDIES" => "PRLS",
"PERSIAN" => "PERS",
"PHILOSOPHY" => "PHIL",
"PHYSICAL EDUCATION" => "PHED",
"PHYSICS" => "PHYS",
"POLICY AND GOVERNMENT" => "POGO",
"PORTUGUESE" => "PORT",
"PROFESSIONAL DEVELOPMENT IN EDUCATION" => "EDPD",
"PROVOST" => "PROV",
"PSYCHOLOGY" => "PSYC",
"PUBLIC ADMINISTRATION" => "PUAD",
"PUBLIC POLICY" => "PUBP",
"READING" => "EDRD",
"REAL ESTATE DEVELOPMENT" => "REAL",
"RECREATION" => "RECR",
"REHABILITATION SCIENCE" => "RHBS",
"RELIGIOUS STUDIES" => "RELI",
"RUSSIAN" => "RUSS",
"SCHOOL OF MANAGEMENT" => "SOM",
"SCHOOL PSYCHOLOGY" => "SPSY",
"SOCIAL WORK" => "SOCW",
"SOCIOLOGY AND ANTHROPOLOGY" => "SOAN",
"SOCIOLOGY" => "SOCI",
"SOFTWARE ENGINEERING" => "SWE",
"SPANISH" => "SPAN",
"SPECIAL EDUCATION" => "EDSE",
"SPORT MANAGEMENT" => "SPMT",
"SPORTS AND RECREATION STUDIES" => "SRST",
"STATISTICS" => "STAT",
"SYSTEM ENGINEERING" => "SYST",
"SYSTEMS ENGINEERING AND OPERATIONS RESEARCH" => "SEOR",
"TECHNOLOGY MANAGEMENT" => "TECM",
"TELECOMMUNICATIONS" => "TCOM",
"THEATER" => "THR",
"TOURISM AND EVENTS MANAGEMENT" => "TOUR",
"TURKISH" => "TURK",
"UNIVERSITY STUDIES" => "UNIV",
"URBAN AND SUBURBAN STUDIES" => "USST",
"VOLGENAU SCHOOL OF ENGINEERING" => "VSE",
"WOMEN AND GENDER STUDIES" => "WMS",
"1" => "I",
"2" => "II",
"3" => "III",
"4" => "IV",
"5" => "V"
}
def self.replace!(input)
@@replacements.each do |thing, replacement|
@replacements.each do |thing, replacement|
# We want each instance of thing to be it's own word
input.gsub!(/(?<= |^)#{thing}(?= |$)/, replacement)
end
end
end
\ No newline at end of file
end
......@@ -65,25 +65,24 @@ class Course < ApplicationRecord
def self.parse_generic_query(query)
query.upcase!
CourseReplacementHelper.replace!(query)
filters = {}
query.scan(/(?<= |^)([a-zA-Z]{2,4})(?=$| )/).each do |a|
s = a[0]
if from_subject(select("*"), s).count > 0
if from_subject(select("*"), s).count.positive?
filters["subject"] = s
query.remove!(s)
end
end
query.scan(/(?<= |^)(\d{3})(?=$| )/).each do |a|
s = a[0]
if filters.include? "subject" and from_course_number(from_subject(select("*"), filters["subject"]), s).count > 0
filters["course_number"] = s
query.remove!(s)
return filters
end
next unless filters.include?("subject") || from_course_number(from_subject(select("*"), filters["subject"]), s).count.positive?
filters["course_number"] = s
query.remove!(s)
return filters
end
filters["title"] = query.gsub(/ +/, " ").strip
filters
end
......
......@@ -57,7 +57,7 @@ class CourseSection < ApplicationRecord
/\d+/.match(query) { |a|
m = a.to_s
if m.length == query.length # Does the number take up the entire query
if m.length == 5 and from_crn(select("*"), m).count != 0 # Check if it is a CRN
if m.length == 5 && from_crn(select("*"), m).count != 0 # Check if it is a CRN
filters["crn"] = m
else # Just assume course_id
filters["course_id"] = Integer(m)
......
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