Skip to content
Merged
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
24 changes: 24 additions & 0 deletions api/controllers/trends.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ func TrendsProfessorSectionSearch(c *gin.Context) {
trendsSectionSearch("Professor", c)
}

// @Id trendsCombinedSectionSearch
// @Router /combined/sections/trends [get]
// @Tags Combined
// @Description "Returns sections matching both course and professor criteria from the combined trends collection. Specialized high-speed convenience endpoint for UTD Trends internal use; limited query flexibility."
// @Produce json
// @Param course_number query string true "The course's official number"
// @Param subject_prefix query string true "The course's subject prefix"
// @Param first_name query string true "The professor's first name"
// @Param last_name query string true "The professor's last name"
// @Success 200 {object} schema.APIResponse[[]schema.Section] "A list of Sections"
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
func TrendsCombinedSectionSearch(c *gin.Context) {
trendsSectionSearch("Combined", c)
}

// trendsSectionSearch handles trends-based section routes for both course and professor query.
// Reduce the repetitiveness of routes whose aggregation behaviors are identical.
// This is subject to change as requests might be more complex.
Expand Down Expand Up @@ -66,6 +81,15 @@ func trendsSectionSearch(flag string, c *gin.Context) {
if err != nil {
return
}
case "Combined":
trendsCollection = configs.GetCollection("trends_course_and_prof_sections")
trendsQuery = bson.M{
"_id": bson.M{
"course": c.Query("subject_prefix") + c.Query("course_number"),
"prof_first": c.Query("first_name"),
"prof_last": c.Query("last_name"),
},
}
default:
// This should never happen, but act as a fallback
err = fmt.Errorf("invalid flag for trendsSectionSearch: %s", flag)
Expand Down
36 changes: 36 additions & 0 deletions api/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,46 @@ const docTemplate = `{
}
}
},
"/combined/sections/trends": {
"get": {
"description": "\"Returns sections matching both course and professor criteria from the combined trends collection. Specialized high-speed convenience endpoint for UTD Trends internal use; limited query flexibility.\"",
"/club/search": {
"get": {
"description": "\"Returns list of clubs matching the search string\"",
"produces": [
"application/json"
],
"tags": [
"Combined"
],
"operationId": "trendsCombinedSectionSearch",
"parameters": [
{
"type": "string",
"description": "The course's official number",
"name": "course_number",
"in": "query",
"required": true
},
{
"type": "string",
"description": "The course's subject prefix",
"name": "subject_prefix",
"in": "query",
"required": true
},
{
"type": "string",
"description": "The professor's first name",
"name": "first_name",
"in": "query",
"required": true
},
{
"type": "string",
"description": "The professor's last name",
"name": "last_name",
"in": "query",
"Clubs"
],
"operationId": "clubSearch",
Expand Down Expand Up @@ -379,6 +412,9 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "A list of Sections",
"schema": {
"$ref": "#/definitions/schema.APIResponse-array_schema_Section"
"description": "A club",
"schema": {
"$ref": "#/definitions/schema.APIResponse-schema_Club"
Expand Down
29 changes: 29 additions & 0 deletions api/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,31 @@ paths:
$ref: '#/definitions/schema.APIResponse-string'
tags:
- Events
/combined/sections/trends:
get:
description: '"Returns sections matching both course and professor criteria
from the combined trends collection. Specialized high-speed convenience endpoint
for UTD Trends internal use; limited query flexibility."'
operationId: trendsCombinedSectionSearch
parameters:
- description: The course's official number
in: query
name: course_number
required: true
type: string
- description: The course's subject prefix
in: query
name: subject_prefix
required: true
type: string
- description: The professor's first name
in: query
name: first_name
required: true
type: string
- description: The professor's last name
in: query
name: last_name
/club/{id}:
get:
description: '"Returns the directory info for given club."'
Expand Down Expand Up @@ -1225,6 +1250,9 @@ paths:
- application/json
responses:
"200":
description: A list of Sections
schema:
$ref: '#/definitions/schema.APIResponse-array_schema_Section'
description: List of matching clubs
schema:
$ref: '#/definitions/schema.APIResponse-array_schema_Club'
Expand All @@ -1237,6 +1265,7 @@ paths:
schema:
$ref: '#/definitions/schema.APIResponse-string'
tags:
- Combined
- Clubs
/course:
get:
Expand Down
12 changes: 12 additions & 0 deletions api/routes/combined.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package routes

import (
"github.com/UTDNebula/nebula-api/api/controllers"
"github.com/gin-gonic/gin"
)

func CombinedRoute(router *gin.Engine) {
combinedGroup := router.Group("/combined")
combinedGroup.OPTIONS("", controllers.Preflight)
combinedGroup.GET("/sections/trends", controllers.TrendsCombinedSectionSearch)
}
1 change: 1 addition & 0 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func main() {
routes.CourseRoute(router)
routes.SectionRoute(router)
routes.ProfessorRoute(router)
routes.CombinedRoute(router)
routes.GradesRoute(router)
routes.AutocompleteRoute(router)
routes.StorageRoute(router)
Expand Down
Loading