Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
schedules
Commits
02e77ac7
Commit
02e77ac7
authored
Sep 30, 2018
by
Zach Perkins
Browse files
Me being indecisive about file locations
parent
63801f60
Changes
3
Hide whitespace changes
Inline
Side-by-side
schedules/app/helpers/course_listings_helper.rb
0 → 100644
View file @
02e77ac7
module
CourseListingsHelper
class
CourseListing
def
initialize
(
course
)
@course
=
course
@sections
=
course
end
def
self
.
wrap
(
course_list
)
course_listings
=
[]
course_list
.
each
do
|
course
|
course_listings
.
push
(
CourseListing
.
new
(
course
))
end
course_listings
end
end
end
\ No newline at end of file
schedules/app/helpers/courses_helper.rb
View file @
02e77ac7
module
CoursesHelper
class
CourseListing
def
initialize
(
course
)
@course
=
course
@sections
=
course
end
def
self
.
wrap
(
course_list
)
course_listings
=
[]
course_list
.
each
do
|
course
|
course_listings
.
push
(
CourseListing
.
new
(
course
))
end
course_listings
end
end
class
GenericItem
def
initialize
(
type
,
data
)
@type
=
type
@data
=
data
end
def
self
.
fetchall
(
query_string
)
models
=
[]
models
.
push
(
fetch_instructors
query_string
)
models
.
push
(
fetch_courses
query_string
)
build_list
(
models
)
end
def
self
.
fetch_instructors
(
query_string
)
Instructor
.
from_name
(
Instructor
.
select
(
"*"
),
query_string
).
all
end
def
self
.
fetch_courses
(
query_string
)
query_string
.
upcase!
CourseReplacementHelper
.
replace!
(
query_string
)
base_query
=
Course
.
select
(
"*"
)
subj
=
nil
query_string
.
scan
(
/(?<= |^)([a-zA-Z]{2,4})(?=$| )/
).
each
do
|
a
|
s
=
a
[
0
]
if
Course
.
from_subject
(
select
(
"*"
),
s
).
count
.
positive?
subj
=
s
base_query
=
Course
.
from_subject
(
base_query
,
subj
)
query_string
.
remove!
(
s
)
end
end
query_string
.
scan
(
/(?<= |^)(\d{3})(?=$| )/
).
each
do
|
a
|
s
=
a
[
0
]
next
unless
!
subj
.
nil?
&&
from_course_number
(
from_subject
(
select
(
"*"
),
subj
),
s
).
count
.
positive?
base_query
=
Course
.
from_course_number
(
s
)
return
base_query
.
all
end
base_query
=
Course
.
from_title
(
query_string
.
gsub
(
/ +/
,
" "
).
strip
)
base_query
.
all
end
# Given a set of models, create a list of GenericItems for each model's data
def
self
.
build_list
(
models
)
list
=
[]
models
.
each
do
|
model
|
list
.
push
(
GenericItem
.
new
(
model
.
name
,
model
))
end
list
end
end
end
schedules/app/helpers/search_helper.rb
View file @
02e77ac7
module
SearchHelper
class
GenericItem
def
initialize
(
type
,
data
)
@type
=
type
@data
=
data
end
def
self
.
fetchall
(
query_string
)
models
=
[]
models
.
push
(
fetch_instructors
query_string
)
models
.
push
(
fetch_courses
query_string
)
build_list
(
models
)
end
def
self
.
fetch_instructors
(
query_string
)
Instructor
.
from_name
(
Instructor
.
select
(
"*"
),
query_string
).
all
end
def
self
.
fetch_courses
(
query_string
)
query_string
.
upcase!
CourseReplacementHelper
.
replace!
(
query_string
)
base_query
=
Course
.
select
(
"*"
)
subj
=
nil
query_string
.
scan
(
/(?<= |^)([a-zA-Z]{2,4})(?=$| )/
).
each
do
|
a
|
s
=
a
[
0
]
if
Course
.
from_subject
(
select
(
"*"
),
s
).
count
.
positive?
subj
=
s
base_query
=
Course
.
from_subject
(
base_query
,
subj
)
query_string
.
remove!
(
s
)
end
end
query_string
.
scan
(
/(?<= |^)(\d{3})(?=$| )/
).
each
do
|
a
|
s
=
a
[
0
]
next
unless
!
subj
.
nil?
&&
from_course_number
(
from_subject
(
select
(
"*"
),
subj
),
s
).
count
.
positive?
base_query
=
Course
.
from_course_number
(
s
)
return
base_query
.
all
end
base_query
=
Course
.
from_title
(
query_string
.
gsub
(
/ +/
,
" "
).
strip
)
base_query
.
all
end
# Given a set of models, create a list of GenericItems for each model's data
def
self
.
build_list
(
models
)
list
=
[]
models
.
each
do
|
model
|
list
.
push
(
GenericItem
.
new
(
model
.
name
,
model
))
end
list
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment