Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions api/controllers/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,56 @@ func EventsByBuilding(c *gin.Context) {

respond(c, http.StatusOK, "success", eventsByBuilding)
}

// @Id eventsByRoomSection
// @Router /events/{date}/{building}/{room}/{sections} [get]
// @Description "Returns all sections (now, as a section object) with meetings on the specified date in the specified building"
// @Produce json
// @Param date path string true "ISO date of the set of events to get"
// @Param building path string true "building abbreviation of the event location"
// @Param room path string true "section ID (ObjectID)"
// @Success 200 {object} schema.APIResponse[[]schema.SectionWithTime] "All sections with meetings on the specified date in the specified building""All sections with meetings on the specified date in the specified building"
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 404 {object} schema.APIResponse[string] "A string describing the error"
func EventsByRoomSection(c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

date := c.Param("date")
building := c.Param("building")
room := c.Param("room")

var events schema.MultiBuildingEvents[schema.SectionWithTime]
var foundSections []schema.SectionWithTime

// find and parse matching date
err := eventsCollection.FindOne(ctx, bson.M{"date": date}).Decode(&events)
if err != nil {
respondWithInternalError(c, err)
return
}

// filter for the specified building and room
for _, b := range events.Buildings {
if b.Building == building {
for _, r := range b.Rooms {
if r.Room == room {
foundSections = r.Events
break
}
}
}
}

if len(foundSections) == 0 {
c.JSON(http.StatusNotFound, schema.APIResponse[string]{
Status: http.StatusNotFound,
Message: "error",
Data: "No events found for the specified building and room",
})
return
}

// return all sections in the room
respond(c, http.StatusOK, "success", foundSections)
}
56 changes: 28 additions & 28 deletions api/controllers/section.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,32 +123,32 @@ func SectionById(c *gin.Context) {
// @Router /section/courses [get]
// @Description "Returns paginated list of courses of all the sections matching the query's string-typed key-value pairs. See former_offset and latter_offset for pagination details."
// @Produce json
// @Param former_offset query number false "The starting position of the current page of professors (e.g. For starting at the 17th professor, former_offset=16)."
// @Param former_offset query number false "The starting position of the current page of professors (e.g. For starting at the 17th professor, former_offset=16)."
// @Param latter_offset query number false "The starting position of the current page of sections (e.g. For starting at the 17th professor, offset=16)."
// @Param section_number query string false "The section's official number"
// @Param academic_session.name query string false "The name of the academic session of the section"
// @Param academic_session.start_date query string false "The date of classes starting for the section"
// @Param academic_session.end_date query string false "The date of classes ending for the section"
// @Param teaching_assistants.first_name query string false "The first name of one of the teaching assistants of the section"
// @Param teaching_assistants.last_name query string false "The last name of one of the teaching assistants of the section"
// @Param teaching_assistants.role query string false "The role of one of the teaching assistants of the section"
// @Param teaching_assistants.email query string false "The email of one of the teaching assistants of the section"
// @Param internal_class_number query string false "The internal (university) number used to reference this section"
// @Param instruction_mode query string false "The instruction modality for this section"
// @Param meetings.start_date query string false "The start date of one of the section's meetings"
// @Param meetings.end_date query string false "The end date of one of the section's meetings"
// @Param meetings.meeting_days query string false "One of the days that one of the section's meetings"
// @Param meetings.start_time query string false "The time one of the section's meetings starts"
// @Param meetings.end_time query string false "The time one of the section's meetings ends"
// @Param meetings.modality query string false "The modality of one of the section's meetings"
// @Param meetings.location.building query string false "The building of one of the section's meetings"
// @Param meetings.location.room query string false "The room of one of the section's meetings"
// @Param meetings.location.map_uri query string false "A hyperlink to the UTD room locator of one of the section's meetings"
// @Param core_flags query string false "One of core requirement codes this section fulfills"
// @Param syllabus_uri query string false "A link to the syllabus on the web"
// @Param section_number query string false "The section's official number"
// @Param academic_session.name query string false "The name of the academic session of the section"
// @Param academic_session.start_date query string false "The date of classes starting for the section"
// @Param academic_session.end_date query string false "The date of classes ending for the section"
// @Param teaching_assistants.first_name query string false "The first name of one of the teaching assistants of the section"
// @Param teaching_assistants.last_name query string false "The last name of one of the teaching assistants of the section"
// @Param teaching_assistants.role query string false "The role of one of the teaching assistants of the section"
// @Param teaching_assistants.email query string false "The email of one of the teaching assistants of the section"
// @Param internal_class_number query string false "The internal (university) number used to reference this section"
// @Param instruction_mode query string false "The instruction modality for this section"
// @Param meetings.start_date query string false "The start date of one of the section's meetings"
// @Param meetings.end_date query string false "The end date of one of the section's meetings"
// @Param meetings.meeting_days query string false "One of the days that one of the section's meetings"
// @Param meetings.start_time query string false "The time one of the section's meetings starts"
// @Param meetings.end_time query string false "The time one of the section's meetings ends"
// @Param meetings.modality query string false "The modality of one of the section's meetings"
// @Param meetings.location.building query string false "The building of one of the section's meetings"
// @Param meetings.location.room query string false "The room of one of the section's meetings"
// @Param meetings.location.map_uri query string false "A hyperlink to the UTD room locator of one of the section's meetings"
// @Param core_flags query string false "One of core requirement codes this section fulfills"
// @Param syllabus_uri query string false "A link to the syllabus on the web"
// @Success 200 {object} schema.APIResponse[[]schema.Course] "A list of courses"
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 400 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 400 {object} schema.APIResponse[string] "A string describing the error"
func SectionCourseSearch() gin.HandlerFunc {
return func(c *gin.Context) {
sectionCourse("Search", c)
Expand All @@ -159,10 +159,10 @@ func SectionCourseSearch() gin.HandlerFunc {
// @Router /section/{id}/course [get]
// @Description "Returns the course of the section with given ID"
// @Produce json
// @Param id path string true "ID of the section to get"
// @Param id path string true "ID of the section to get"
// @Success 200 {object} schema.APIResponse[schema.Course] "A course"
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 400 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 400 {object} schema.APIResponse[string] "A string describing the error"
func SectionCourseById() gin.HandlerFunc {
return func(c *gin.Context) {
sectionCourse("ById", c)
Expand Down Expand Up @@ -251,7 +251,7 @@ func sectionCourse(flag string, c *gin.Context) {
// @Description "Returns paginated list of professors of all the sections matching the query's string-typed key-value pairs. See former_offset and latter_offset for pagination details."
// @Produce json
// @Param former_offset query number false "The starting position of the current page of professors (e.g. For starting at the 17th professor, former_offset=16)."
// @Param latter_offset query number false "The starting position of the current page of sections (e.g. For starting at the 17th professor, offset=16)."
// @Param latter_offset query number false "The starting position of the current page of sections (e.g. For starting at the 17th professor, offset=16)."
// @Param section_number query string false "The section's official number"
// @Param academic_session.name query string false "The name of the academic session of the section"
// @Param academic_session.start_date query string false "The date of classes starting for the section"
Expand Down
52 changes: 25 additions & 27 deletions api/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1631,13 +1631,13 @@ const docTemplate = `{
"parameters": [
{
"type": "number",
"description": "The starting position of the current page of sections (e.g. For starting at the 17th section, former_offset=16).",
"description": "The starting position of the current page of professors (e.g. For starting at the 17th professor, former_offset=16).",
"name": "former_offset",
"in": "query"
},
{
"type": "number",
"description": "The starting position of the current page of courses from the predefined page of sections (e.g. For starting at the 18th course, latter_offset=17).",
"description": "The starting position of the current page of sections (e.g. For starting at the 17th professor, offset=16).",
"name": "latter_offset",
"in": "query"
},
Expand Down Expand Up @@ -1800,13 +1800,13 @@ const docTemplate = `{
"parameters": [
{
"type": "number",
"description": "The starting position of the current page of sections (e.g. For starting at the 17th section, former_offset=16).",
"description": "The starting position of the current page of professors (e.g. For starting at the 17th professor, former_offset=16).",
"name": "former_offset",
"in": "query"
},
{
"type": "number",
"description": "The starting position of the current page of professors from the predefined page of sections (e.g. For starting at the 18th professor, latter_offset=17).",
"description": "The starting position of the current page of sections (e.g. For starting at the 17th professor, offset=16).",
"name": "latter_offset",
"in": "query"
},
Expand Down Expand Up @@ -2338,7 +2338,7 @@ const docTemplate = `{
"required": true
},
{
"description": "params for Signed URL",
"description": "Request body",
"name": "body",
"in": "body",
"required": true,
Expand Down Expand Up @@ -2393,28 +2393,6 @@ const docTemplate = `{
}
},
"definitions": {
"schema.ObjectSignedURLBody": {
"description": "request body",
"type": "object",
"properties": {
"expiration": {
"description": "timestamp for when the signed URL will expire",
"type": "string"
},
"headers": {
"description": "headers for signed URL",
"type": "array",
"items": {
"type": "string"
}
},
"method": {
"description": "method to be used with signed URL",
"type": "string",
"example": "PUT"
}
}
},
"schema.APIResponse-array_int": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -3103,6 +3081,26 @@ const docTemplate = `{
}
}
},
"schema.ObjectSignedURLBody": {
"type": "object",
"properties": {
"expiration": {
"description": "timestamp for when the signed URL will expire",
"type": "string"
},
"headers": {
"description": "headers for signed URL",
"type": "array",
"items": {
"type": "string"
}
},
"method": {
"description": "method to be used with signed URL. For example, PUT",
"type": "string"
}
}
},
"schema.Professor": {
"type": "object",
"properties": {
Expand Down
51 changes: 24 additions & 27 deletions api/docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
definitions:
schema.ObjectSignedURLBody:
description: request body
properties:
expiration:
description: timestamp for when the signed URL will expire
type: string
headers:
description: headers for signed URL
items:
type: string
type: array
method:
description: method to be used with signed URL
example: PUT
type: string
type: object
schema.APIResponse-array_int:
properties:
data:
Expand Down Expand Up @@ -462,6 +446,20 @@ definitions:
updated:
type: string
type: object
schema.ObjectSignedURLBody:
properties:
expiration:
description: timestamp for when the signed URL will expire
type: string
headers:
description: headers for signed URL
items:
type: string
type: array
method:
description: method to be used with signed URL. For example, PUT
type: string
type: object
schema.Professor:
properties:
_id:
Expand Down Expand Up @@ -1773,8 +1771,7 @@ paths:
$ref: '#/definitions/schema.APIResponse-string'
/section/{id}/course:
get:
description: '"Returns the course of the section with given
ID"'
description: '"Returns the course of the section with given ID"'
operationId: sectionCourseById
parameters:
- description: ID of the section to get
Expand Down Expand Up @@ -1855,13 +1852,13 @@ paths:
for pagination details."'
operationId: sectionCourseSearch
parameters:
- description: The starting position of the current page of sections (e.g.
For starting at the 17th section, former_offset=16).
- description: The starting position of the current page of professors (e.g.
For starting at the 17th professor, former_offset=16).
in: query
name: former_offset
type: number
- description: The starting position of the current page of courses (e.g. For
starting at the 4th course, latter_offset=3).
- description: The starting position of the current page of sections (e.g. For
starting at the 17th professor, offset=16).
in: query
name: latter_offset
type: number
Expand Down Expand Up @@ -1971,13 +1968,13 @@ paths:
for pagination details."'
operationId: sectionProfessorSearch
parameters:
- description: The starting position of the current page of sections (e.g.
For starting at the 17th section, former_offset=16).
- description: The starting position of the current page of professors (e.g.
For starting at the 17th professor, former_offset=16).
in: query
name: former_offset
type: number
- description: The starting position of the current page of professors (e.g. For
starting at the 4th professor, latter_offset=3).
- description: The starting position of the current page of sections (e.g. For
starting at the 17th professor, offset=16).
in: query
name: latter_offset
type: number
Expand Down Expand Up @@ -2240,7 +2237,7 @@ paths:
name: objectID
required: true
type: string
- description: Request body
- description: Request body
in: body
name: body
required: true
Expand Down
1 change: 1 addition & 0 deletions api/routes/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ func EventsRoute(router *gin.Engine) {
eventsGroup.OPTIONS("", controllers.Preflight)
eventsGroup.GET(":date", controllers.Events)
eventsGroup.GET(":date/:building", controllers.EventsByBuilding)
eventsGroup.GET(":date/:building/:room/sections", controllers.EventsByRoomSection)
}
2 changes: 1 addition & 1 deletion api/routes/grades.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func GradesRoute(router *gin.Engine) {

gradesGroup.OPTIONS("", controllers.Preflight)

// @TODO: Do we need this?
// @TODO: Do we need this?
// ---- gradesGroup.OPTIONS("semester", controllers.Preflight)
// ---- gradesGroup.OPTIONS("overall", controllers.Preflight)

Expand Down
Loading
Loading