Open TyHil opened 1 week ago
This seems interesting. Can I work on this ?
This seems interesting. Can I work on this ?
Definitely! This will likely involve setting up some more sophisticated aggregation pipelines since ideally we want to avoid needing to do any sort of schema changes to accommodate this.
Hi @jpahm, I've made some significant progress in modifying the existing stages (if needed) and making additional stages for the section-type pipeline. It works as expected, but I have a few questions.
Function gradesAggregation()
is already long enough, so modification would make it even longer. Do you feel the need to modularize the function? Though I think modularizing function further would also be quite challenging since each part in the function is closely connected.
You suggested that we want to avoid making any changes to schema. But then fields of the response wouldn't be in the desirable order. I have to add the following to grades_response.go
:
type SectionTypeGradeResponse struct {
Status int `json:"status"`
Message string `json:"message"`
OverallData []OverallData `json:"overall_data"`
}
type OverallData struct {
Id string `bson:"_id" json:"_id"`
Data []typeGradeData `bson:"data" json:"data"`
}
type typeGradeData struct {
Type string `bson:"type" json:"type"`
GradeDistribution interface{} `bson:"grade_distribution" json:"grade_distribution"`
}
The response then would be:
[
{
"_id": string, //ex 22S
"data": [
{
"type": string, //ex 0xx
"grade_distribution": number[14]
},
...
]
},
...
]
If I instead only used interface{}
, the response would be:
[
{
"_id": string, //ex 22S
"data": [
{
// the fields are swapped here (possibly not we want, I don't know)
"grade_distribution": number[14],
"type": string, //ex 0xx
},
...
]
},
...
]
Do you think it's fine if I just need to use interface{}
or I should keep the change ?
Should the response have all section types listed even when some types have empty array? For example, the response to grades/semester/sectionType?first_name=Yi&last_name=Zhao
would be:
{
"_id": "23F",
"data": [
{
"type": "0xx",
"grade_distribution": [ ]
},
{
"type": "5xx",
"grade_distribution": [ ]
}
]
},
because that semester only has 2 sections.
Thank you.
Overview
Trends is looking to add a new filter for grade data to aggregate based on section type. The UTD section types are as follows:
Changes
Currently Trends has a filter for semester which is why Trends uses the
/grades/semester
endpoint.This issue is to create a new endpoint:
/grades/semester/sectionType
that returns grade data broken down by semester and then by section type within each semester. This would involve changes to the api/controllers/grades.go file.Response format
/grades/semester
response format/grades/semester/sectionType
response format