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
76 changes: 76 additions & 0 deletions uploader/pipelines/trends_course_and_prof_section.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package pipelines

import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
)

var TrendsCourseProfSectionsPipeline = mongo.Pipeline{

bson.D{
{Key: "$lookup",
Value: bson.D{
{Key: "from", Value: "sections"},
{Key: "localField", Value: "sections"},
{Key: "foreignField", Value: "_id"},
{Key: "as", Value: "sections"},
},
},
},
bson.D{
{Key: "$group",
Value: bson.D{
{Key: "subject_prefix", Value: 1},
{Key: "course_number", Value: 1},
{Key: "sections", Value: 1},
},
},
},

bson.D{
{Key: "$unwind",
Value: bson.D{
{Key: "path", Value: "$sections"},
{Key: "preserveNullAndEmptyArrays", Value: false},
},
},
},
bson.D{
{Key: "$lookup",
Value: bson.D{
{Key: "from", Value: "professors"},
{Key: "localField", Value: "sections.professors"},
{Key: "foreignField", Value: "_id"},
{Key: "as", Value: "professors"},
},
},
},
bson.D{
{Key: "$unwind",
Value: bson.D{
{Key: "path", Value: "$sections"},
{Key: "preserveNullAndEmptyArrays", Value: false},
},
},
},

bson.D{
{Key: "$group",
Value: bson.D{
{Key: "_id",
Value: bson.D{
{Key: "$concat",
Value: bson.A{
"$subject_prefix",
"$course_number",
"$professors.first_name",
"$professors.last_name",
},
},
},
},
{Key: "sections", Value: bson.D{{Key: "$addToSet", Value: "$sections"}}},
},
},
},
}
1 change: 1 addition & 0 deletions uploader/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func Upload(inDir string, replace bool, staticOnly bool) {
buildStaticAggregation(client, ctx, "sections", "events", pipelines.EventsPipeline)
buildStaticAggregation(client, ctx, "courses", "trends_course_sections", pipelines.TrendsCourseSectionsPipeline)
buildStaticAggregation(client, ctx, "professors", "trends_prof_sections", pipelines.TrendsProfSectionsPipeline)
buildStaticAggregation(client, ctx, "courses+professors", "trends_course_and_prof_section", pipelines.TrendsCourseProfSectionsPipeline)

log.Print("Done building static aggregations!")
}
Expand Down