Skip to content

Commit 9435f4f

Browse files
committed
Merge from nebula-api/develop
2 parents 4623a9c + 10e4034 commit 9435f4f

File tree

4 files changed

+201
-11
lines changed

4 files changed

+201
-11
lines changed

api/controllers/astra.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@ func AstraEventsByBuilding(c *gin.Context) {
8585
}
8686

8787
if astra_eventsByBuilding.Building == "" {
88-
c.JSON(http.StatusNotFound, schema.APIResponse[string]{
89-
Status: http.StatusNotFound,
90-
Message: "error",
91-
Data: "No events found for the specified building",
92-
})
88+
respond(c, http.StatusNotFound, "error", "No events found for the specified building")
9389
return
9490
}
9591

@@ -144,11 +140,7 @@ func AstraEventsByBuildingAndRoom(c *gin.Context) {
144140
}
145141

146142
if roomEvents.Room == "" {
147-
c.JSON(http.StatusNotFound, schema.APIResponse[string]{
148-
Status: http.StatusNotFound,
149-
Message: "error",
150-
Data: "No rooms found for the specified building or event",
151-
})
143+
respond(c, http.StatusNotFound, "error", "No rooms found for the specified building or event")
152144
return
153145
}
154146

api/controllers/grades.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func GradesByProfessorID() gin.HandlerFunc {
156156
// base function, returns the grade distribution depending on type of flag
157157
func gradesAggregation(flag string, c *gin.Context) {
158158
var grades []schema.GradeData
159-
var results []map[string]interface{}
159+
var results []map[string]any
160160

161161
var sectionTypeGrades []schema.TypedGradeData // used to parse the response to section-type endpoints
162162

api/docs/docs.go

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,109 @@ const docTemplate = `{
5050
}
5151
}
5252
},
53+
"/astra/{date}/{building}": {
54+
"get": {
55+
"description": "\"Returns AstraEvent based on the input date and building name\"",
56+
"produces": [
57+
"application/json"
58+
],
59+
"tags": [
60+
"Events"
61+
],
62+
"operationId": "AstraEventsByBuilding",
63+
"parameters": [
64+
{
65+
"type": "string",
66+
"description": "date (ISO format) to retrieve astra events",
67+
"name": "date",
68+
"in": "path",
69+
"required": true
70+
},
71+
{
72+
"type": "string",
73+
"description": "building abbreviation of event locations",
74+
"name": "building",
75+
"in": "path",
76+
"required": true
77+
}
78+
],
79+
"responses": {
80+
"200": {
81+
"description": "All sections with meetings on the specified date in the specified building",
82+
"schema": {
83+
"$ref": "#/definitions/schema.APIResponse-schema_SingleBuildingEvents-schema_AstraEvent"
84+
}
85+
},
86+
"404": {
87+
"description": "A string describing the error",
88+
"schema": {
89+
"$ref": "#/definitions/schema.APIResponse-string"
90+
}
91+
},
92+
"500": {
93+
"description": "A string describing the error",
94+
"schema": {
95+
"$ref": "#/definitions/schema.APIResponse-string"
96+
}
97+
}
98+
}
99+
}
100+
},
101+
"/astra/{date}/{building}/{room}": {
102+
"get": {
103+
"description": "\"Returns AstraEvent based on the input date building name and room number\"",
104+
"produces": [
105+
"application/json"
106+
],
107+
"tags": [
108+
"Events"
109+
],
110+
"operationId": "AstraEventsByBuildingandRoom",
111+
"parameters": [
112+
{
113+
"type": "string",
114+
"description": "date (ISO format) to retrieve astra events",
115+
"name": "date",
116+
"in": "path",
117+
"required": true
118+
},
119+
{
120+
"type": "string",
121+
"description": "building abbreviation of event locations",
122+
"name": "building",
123+
"in": "path",
124+
"required": true
125+
},
126+
{
127+
"type": "string",
128+
"description": "room number for event",
129+
"name": "room",
130+
"in": "path",
131+
"required": true
132+
}
133+
],
134+
"responses": {
135+
"200": {
136+
"description": "All sections with meetings on the specified date in the specified building",
137+
"schema": {
138+
"$ref": "#/definitions/schema.APIResponse-schema_SingleBuildingEvents-schema_AstraEvent"
139+
}
140+
},
141+
"404": {
142+
"description": "A string describing the error",
143+
"schema": {
144+
"$ref": "#/definitions/schema.APIResponse-string"
145+
}
146+
},
147+
"500": {
148+
"description": "A string describing the error",
149+
"schema": {
150+
"$ref": "#/definitions/schema.APIResponse-string"
151+
}
152+
}
153+
}
154+
}
155+
},
53156
"/autocomplete/dag": {
54157
"get": {
55158
"description": "\"Returns an aggregation of courses for use in generating autocomplete DAGs\"",
@@ -3069,6 +3172,20 @@ const docTemplate = `{
30693172
}
30703173
}
30713174
},
3175+
"schema.APIResponse-schema_SingleBuildingEvents-schema_AstraEvent": {
3176+
"type": "object",
3177+
"properties": {
3178+
"data": {
3179+
"$ref": "#/definitions/schema.SingleBuildingEvents-schema_AstraEvent"
3180+
},
3181+
"message": {
3182+
"type": "string"
3183+
},
3184+
"status": {
3185+
"type": "integer"
3186+
}
3187+
}
3188+
},
30723189
"schema.APIResponse-schema_SingleBuildingEvents-schema_SectionWithTime": {
30733190
"type": "object",
30743191
"properties": {

api/docs/swagger.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,15 @@ definitions:
186186
status:
187187
type: integer
188188
type: object
189+
schema.APIResponse-schema_SingleBuildingEvents-schema_AstraEvent:
190+
properties:
191+
data:
192+
$ref: '#/definitions/schema.SingleBuildingEvents-schema_AstraEvent'
193+
message:
194+
type: string
195+
status:
196+
type: integer
197+
type: object
189198
schema.APIResponse-schema_SingleBuildingEvents-schema_SectionWithTime:
190199
properties:
191200
data:
@@ -743,6 +752,78 @@ paths:
743752
$ref: '#/definitions/schema.APIResponse-string'
744753
tags:
745754
- Events
755+
/astra/{date}/{building}:
756+
get:
757+
description: '"Returns AstraEvent based on the input date and building name"'
758+
operationId: AstraEventsByBuilding
759+
parameters:
760+
- description: date (ISO format) to retrieve astra events
761+
in: path
762+
name: date
763+
required: true
764+
type: string
765+
- description: building abbreviation of event locations
766+
in: path
767+
name: building
768+
required: true
769+
type: string
770+
produces:
771+
- application/json
772+
responses:
773+
"200":
774+
description: All sections with meetings on the specified date in the specified
775+
building
776+
schema:
777+
$ref: '#/definitions/schema.APIResponse-schema_SingleBuildingEvents-schema_AstraEvent'
778+
"404":
779+
description: A string describing the error
780+
schema:
781+
$ref: '#/definitions/schema.APIResponse-string'
782+
"500":
783+
description: A string describing the error
784+
schema:
785+
$ref: '#/definitions/schema.APIResponse-string'
786+
tags:
787+
- Events
788+
/astra/{date}/{building}/{room}:
789+
get:
790+
description: '"Returns AstraEvent based on the input date building name and
791+
room number"'
792+
operationId: AstraEventsByBuildingandRoom
793+
parameters:
794+
- description: date (ISO format) to retrieve astra events
795+
in: path
796+
name: date
797+
required: true
798+
type: string
799+
- description: building abbreviation of event locations
800+
in: path
801+
name: building
802+
required: true
803+
type: string
804+
- description: room number for event
805+
in: path
806+
name: room
807+
required: true
808+
type: string
809+
produces:
810+
- application/json
811+
responses:
812+
"200":
813+
description: All sections with meetings on the specified date in the specified
814+
building
815+
schema:
816+
$ref: '#/definitions/schema.APIResponse-schema_SingleBuildingEvents-schema_AstraEvent'
817+
"404":
818+
description: A string describing the error
819+
schema:
820+
$ref: '#/definitions/schema.APIResponse-string'
821+
"500":
822+
description: A string describing the error
823+
schema:
824+
$ref: '#/definitions/schema.APIResponse-string'
825+
tags:
826+
- Events
746827
/autocomplete/dag:
747828
get:
748829
description: '"Returns an aggregation of courses for use in generating autocomplete

0 commit comments

Comments
 (0)