Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
schedules
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
11
Issues
11
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
schedules
Commits
83a1b1c8
Commit
83a1b1c8
authored
Dec 16, 2018
by
Zac Wood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Schedule generation is now truly deterministic, made cookies permanent
parent
f45f549b
Pipeline
#3498
canceled with stages
in 1 minute and 35 seconds
Changes
8
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
20 additions
and
42 deletions
+20
-42
docker-compose.yml
docker-compose.yml
+0
-18
init.sh
init.sh
+0
-13
schedules/app/controllers/application_controller.rb
schedules/app/controllers/application_controller.rb
+3
-3
schedules/app/controllers/schedules_controller.rb
schedules/app/controllers/schedules_controller.rb
+2
-4
schedules/app/controllers/sessions_controller.rb
schedules/app/controllers/sessions_controller.rb
+3
-3
schedules/app/models/course_section.rb
schedules/app/models/course_section.rb
+4
-0
schedules/app/models/schedule.rb
schedules/app/models/schedule.rb
+3
-1
schedules/test/models/course_section_test.rb
schedules/test/models/course_section_test.rb
+5
-0
No files found.
docker-compose.yml
deleted
100644 → 0
View file @
f45f549b
version
:
"
3"
services
:
api
:
image
:
schedules_api
ports
:
-
"
3000:3000"
command
:
./start.sh
volumes
:
-
./schedules_api:/api
web
:
image
:
schedules_web
ports
:
-
"
8080:8080"
command
:
yarn start
volumes
:
-
./schedules_web:/web
init.sh
deleted
100755 → 0
View file @
f45f549b
#! /bin/bash
# Build the API image
cd
schedules_api/
docker build
.
-t
'schedules_api'
-f
Dockerfile.dev
# Build the Web image
cd
../schedules_web
docker build
.
-t
'schedules_web'
-f
Dockerfile.dev
# Start and link the images together
cd
..
docker-compose up
schedules/app/controllers/application_controller.rb
View file @
83a1b1c8
...
...
@@ -15,12 +15,12 @@ class ApplicationController < ActionController::Base
end
def
set_cart
@cart
=
JSON
.
parse
(
cookies
[
:cart
])
@cart
=
JSON
.
parse
(
cookies
.
permanent
[
:cart
])
@cart
=
@cart
.
reject
{
|
crn
|
CourseSection
.
find_by_crn
(
crn
).
nil?
}
cookies
[
:cart
]
=
@cart
.
to_json
cookies
.
permanent
[
:cart
]
=
@cart
.
to_json
end
def
set_cookies
cookies
[
:cart
]
=
"[]"
if
cookies
[
:cart
].
nil?
cookies
.
permanent
[
:cart
]
=
"[]"
if
cookies
.
permanent
[
:cart
].
nil?
end
end
schedules/app/controllers/schedules_controller.rb
View file @
83a1b1c8
...
...
@@ -9,16 +9,14 @@ class SchedulesController < ApplicationController
}
@all
=
valid_crns
.
map
{
|
crn
|
a
=
CourseSection
.
where
(
crn:
crn
).
sort_by
{
|
s
|
s
.
course
.
semester
.
id
}
a
.
first
CourseSection
.
latest_by_crn
(
crn
)
}
@events
=
generate_fullcalender_events
(
@all
)
end
def
view
@all
=
params
[
:crns
].
split
(
','
).
map
{
|
crn
|
a
=
CourseSection
.
where
(
crn:
crn
).
sort_by
{
|
s
|
s
.
course
.
semester
.
id
}
a
.
first
CourseSection
.
latest_by_crn
(
crn
)
}
@events
=
generate_fullcalender_events
(
@all
)
end
...
...
schedules/app/controllers/sessions_controller.rb
View file @
83a1b1c8
...
...
@@ -17,18 +17,18 @@ class SessionsController < ApplicationController
end
puts
@cart
cookies
[
:cart
]
=
@cart
.
to_json
cookies
.
permanent
[
:cart
]
=
@cart
.
to_json
render
json:
@cart
.
to_json
end
def
add_bulk
crns
=
params
[
:crns
].
split
(
','
)
crns
.
each
{
|
crn
|
s
=
CourseSection
.
find
_by_crn
(
crn
)
s
=
CourseSection
.
latest
_by_crn
(
crn
)
next
if
s
.
nil?
@cart
<<
crn
.
to_s
unless
@cart
.
include?
(
crn
.
to_s
)
}
cookies
[
:cart
]
=
@cart
.
to_json
cookies
.
permanent
[
:cart
]
=
@cart
.
to_json
redirect_to
schedule_path
end
...
...
schedules/app/models/course_section.rb
View file @
83a1b1c8
...
...
@@ -17,6 +17,10 @@ class CourseSection < ApplicationRecord
(
t1_start
<=
t2_end
&&
t2_start
<=
t1_end
)
&&
Set
.
new
(
days
.
split
).
intersect?
(
Set
.
new
(
other
.
days
.
split
))
end
def
self
.
latest_by_crn
(
crn
)
where
(
crn:
crn
).
sort_by
{
|
s
|
s
.
course
.
semester
.
id
}.
first
end
# Select all course sections that have an instructor that matches the given name
def
self
.
with_instructor
(
name:
""
)
joins
(
:instructor
)
...
...
schedules/app/models/schedule.rb
View file @
83a1b1c8
...
...
@@ -7,7 +7,9 @@ class Schedule
@cal
=
Icalendar
::
Calendar
.
new
@cal
.
x_wr_calname
=
'GMU Schedule'
@course_sections
=
crns
.
map
{
|
crn
|
CourseSection
.
find_by_crn
crn
}
@course_sections
=
crns
.
map
{
|
crn
|
CourseSection
.
latest_by_crn
(
crn
)
}
@course_sections
.
compact!
load_events
...
...
schedules/test/models/course_section_test.rb
View file @
83a1b1c8
...
...
@@ -21,4 +21,9 @@ class CourseSectionTest < ActiveSupport::TestCase
section
=
CourseSection
.
with_instructor
.
first
assert
section
.
instructor_name
!=
""
end
test
'#latest_by_crn sorts correctly'
do
s
=
CourseSection
.
latest_by_crn
(
70192
)
assert_equal
semesters
(
:fall2018
).
id
,
s
.
course
.
semester
.
id
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