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-legacy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
17
Issues
17
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
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-legacy
Commits
3b4f0dff
Commit
3b4f0dff
authored
Dec 31, 2016
by
Mark Stenglein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Linting and cleanup take 2
parent
a9931416
Pipeline
#713
failed with stage
in 43 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
28 deletions
+31
-28
data/index.js
data/index.js
+7
-7
helpers/index.js
helpers/index.js
+10
-4
routes/api/v1.js
routes/api/v1.js
+14
-17
No files found.
data/index.js
View file @
3b4f0dff
...
...
@@ -133,12 +133,12 @@ var syncSections = function (semester) {
* and or locations.
*/
for
(
var
c
=
0
;
c
<
rawSection
.
session_templates
.
length
;
c
++
)
{
var
session
_t
emplate
=
rawSection
.
session_templates
[
c
]
var
session
T
emplate
=
rawSection
.
session_templates
[
c
]
// raw value of the start/stop times (to be processed to time values)
var
sessionTime
=
session
_t
emplate
.
time
;
var
sessionTime
=
session
T
emplate
.
time
;
([
'
M
'
,
'
T
'
,
'
W
'
,
'
R
'
,
'
F
'
]).
forEach
(
function
(
day
)
{
if
(
session
_t
emplate
.
days
.
indexOf
(
day
)
>
-
1
)
{
if
(
session
T
emplate
.
days
.
indexOf
(
day
)
>
-
1
)
{
// if here then there is a session for the day
section
[
day
+
'
session
'
]
=
true
...
...
@@ -162,16 +162,16 @@ var syncSections = function (semester) {
section
[
day
+
'
timeEnd
'
]
=
sessionTime
.
substr
(
endOffset
,
endLength
)
// Note down location and type information
section
[
day
+
'
location
'
]
=
session
_t
emplate
.
location
section
[
day
+
'
classType
'
]
=
session
_t
emplate
.
class_type
section
[
day
+
'
location
'
]
=
session
T
emplate
.
location
section
[
day
+
'
classType
'
]
=
session
T
emplate
.
class_type
// If the instructor is not yet in the entire listing, add it.
// TODO: Make this tolerant of multiple instructors defined for
// one section. (ie. currently if you have 2 instructors in
// one section it'll search for all of them as one term and
// consequently add all of them to the full list.) Should
if
(
section
.
instructor
.
search
(
session
_t
emplate
.
instructors
)
<
0
)
{
section
.
instructor
+=
session
_t
emplate
.
instructors
if
(
section
.
instructor
.
search
(
session
T
emplate
.
instructors
)
<
0
)
{
section
.
instructor
+=
session
T
emplate
.
instructors
}
}
})
...
...
helpers/index.js
View file @
3b4f0dff
...
...
@@ -11,9 +11,9 @@
* tl;dr: Forget staying thirsty, "Stay DRY, my friends."
*/
//var ical = require('ical-generator') // ical-generator library
//var config = require('config') // Site wide configs
//var db = require('../models') // Database Object
//
var ical = require('ical-generator') // ical-generator library
//
var config = require('config') // Site wide configs
//
var db = require('../models') // Database Object
/*
* A brief note...since this is quite new and I don't know exactly how I want to
...
...
@@ -22,6 +22,12 @@
* TODO: Make this not suck (dynamic loading of other files maybe?)
*/
var
userException
=
function
(
message
)
{
this
.
message
=
message
this
.
name
=
'
userException
'
}
module
.
exports
.
userException
=
userException
/**
* Strip all non alpha numeric characters from input.
*
...
...
@@ -45,7 +51,7 @@ module.exports.strClean = strClean
var
strSplitClean
=
function
(
rawString
,
separator
)
{
// Validate input for separator
if
(
separator
&&
separator
.
length
!==
1
)
{
throw
{
message
:
'
separator must be a single char
'
}
throw
new
userException
(
'
separator must be a single char
'
)
}
if
(
!
separator
)
{
separator
=
'
,
'
...
...
routes/api/v1.js
View file @
3b4f0dff
...
...
@@ -15,12 +15,12 @@ var express = require('express')
var
path
=
require
(
'
path
'
)
var
router
=
express
.
Router
()
var
ical
=
require
(
'
ical-generator
'
)
// ical-generator library
var
config
=
require
(
'
config
'
)
// Site wide configs
//var schoolSlugs = config.get('schoolSlugs') // Configured School Slugs
//
var config = require('config') // Site wide configs
//
var schoolSlugs = config.get('schoolSlugs') // Configured School Slugs
var
db
=
require
(
'
models
'
)
// Database Object
var
helpers
=
require
(
path
.
join
(
__dirname
,
'
..
'
,
'
..
'
,
'
helpers
'
))
var
moment
=
require
(
'
moment
'
)
//var _ = require('lodash')
//
var _ = require('lodash')
// /////////////////////////////////////////////////////////////////////////////
// JSON API Definitions
...
...
@@ -142,7 +142,6 @@ router.get('/json/classes/:SEMESTER/:CRN', function (req, res, next) {
* TODO: Remove the school part of this query...no need because of Sem Slugs
*/
router
.
get
(
'
/ical/:SCHOOL/:SEMSLUG/:SECTIONS
'
,
function
(
req
,
res
,
next
)
{
// Extract arguments and setup empty objects for them
// Get School Information
...
...
@@ -184,16 +183,15 @@ router.get('/ical/:SCHOOL/:SEMSLUG/:SECTIONS', function (req, res, next) {
// Generate blank calendar
var
cal
=
ical
(
{
'
domain
'
:
'
schedules.gmu.edu
'
,
'
prodId
'
:
'
//Student Run Computing and Technology//Schedules//EN
'
,
'
name
'
:
school
.
get
(
'
slug
'
)
+
'
Class Schedule Fall 2016
'
'
domain
'
:
'
schedules.gmu.edu
'
,
'
prodId
'
:
'
//Student Run Computing and Technology//Schedules//EN
'
,
'
name
'
:
school
.
get
(
'
slug
'
)
+
'
Class Schedule Fall 2016
'
}
)
cal
.
setTZ
(
'
America/New_York
'
)
// Build the rest of the calendar
sections
.
forEach
(
function
(
section
)
{
// Fetch the start and end times
var
startDate
=
moment
(
section
.
get
(
'
startDate
'
),
'
MMM DD, YYYY
'
)
var
endDate
=
moment
(
section
.
get
(
'
endDate
'
),
'
MMM DD, YYYY
'
)
...
...
@@ -218,7 +216,7 @@ router.get('/ical/:SCHOOL/:SEMSLUG/:SECTIONS', function (req, res, next) {
endDate
=
endDate
.
add
(
7
,
'
d
'
)
}
var
processTime
=
function
(
time
)
{
var
processTime
=
function
(
time
)
{
var
hour
=
parseInt
(
time
.
substring
(
0
,
2
))
var
min
=
parseInt
(
time
.
substring
(
3
,
5
))
if
(
time
.
substring
(
6
,
8
)
===
'
pm
'
&&
hour
!==
12
)
{
...
...
@@ -237,7 +235,7 @@ router.get('/ical/:SCHOOL/:SEMSLUG/:SECTIONS', function (req, res, next) {
startDateFinish
.
hour
(
endTime
.
hour
)
startDateFinish
.
minute
(
endTime
.
min
)
var
event
=
cal
.
createEvent
({
cal
.
createEvent
({
uid
:
semester
.
get
(
'
slug
'
)
+
'
-
'
+
section
.
get
(
'
crn
'
),
start
:
startDate
.
utc
(
true
).
toDate
(),
end
:
startDateFinish
.
utc
(
true
).
toDate
(),
...
...
@@ -248,16 +246,15 @@ router.get('/ical/:SCHOOL/:SEMSLUG/:SECTIONS', function (req, res, next) {
},
summary
:
section
.
get
(
'
name
'
),
description
:
(
section
.
get
(
'
name
'
)
+
'
:
'
+
section
.
get
(
'
title
'
)
+
'
(
'
+
section
.
get
(
'
class_type
'
)
+
'
)
\n
Section:
'
+
section
.
get
(
'
section
'
)
+
'
\n
Instructors:
'
+
section
.
get
(
'
instructor
'
)
section
.
get
(
'
name
'
)
+
'
:
'
+
section
.
get
(
'
title
'
)
+
'
(
'
+
section
.
get
(
'
class_type
'
)
+
'
)
\n
Section:
'
+
section
.
get
(
'
section
'
)
+
'
\n
Instructors:
'
+
section
.
get
(
'
instructor
'
)
),
organizer
:
'
Mason SRCT <schedules@lists.srct.gmu.edu>
'
,
url
:
'
https://schedules.gmu.edu
'
})
})
})
// TODO: build the calendar events
...
...
@@ -272,10 +269,10 @@ router.get('/ical/:SCHOOL/:SEMSLUG/:SECTIONS', function (req, res, next) {
).
then
(
function
(
queries
)
{
// Check for invalid responses and throw appropriate errors
if
(
!
queries
[
0
])
{
throw
{
message
:
'
Invalid School Given!
'
}
throw
new
helpers
.
userException
(
'
Invalid School Given!
'
)
}
if
(
!
queries
[
1
])
{
throw
{
message
:
'
Invalid Semester Given
'
}
throw
new
helpers
.
userException
(
'
Invalid Semester Given
'
)
}
// Generate the calendar
...
...
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