Skip to content

Commit 7351f3a

Browse files
committed
feat: enhance student regs with zpa data
1 parent 77995a9 commit 7351f3a

9 files changed

Lines changed: 720 additions & 81 deletions

File tree

db/collection.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const (
1818
collectionNamePlanBackup = "plan_backup"
1919

2020
collectionStudentRegsPerStudentPlanned = "studentregs_per_student_planned"
21+
collectionZpaStudents = "zpastudents"
2122

2223
collectionAll = "zpaexams"
2324
collectionToPlan = "zpaexamsToPlan"

db/zpa.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,31 @@ import (
99
"go.mongodb.org/mongo-driver/bson"
1010
)
1111

12+
func (db *DB) GetZPAStudents(ctx context.Context) ([]*model.ZPAStudent, error) {
13+
collection := db.getCollectionSemester(collectionZpaStudents)
14+
15+
cur, err := collection.Find(ctx, bson.M{})
16+
if err != nil {
17+
log.Error().Err(err).Msg("cannot get zpa students")
18+
return nil, err
19+
}
20+
defer cur.Close(ctx) //nolint:errcheck
21+
22+
zpaStudents := make([]*model.ZPAStudent, 0)
23+
24+
err = cur.All(ctx, &zpaStudents)
25+
if err != nil {
26+
log.Error().Err(err).Msg("cannot decode zpa students")
27+
return nil, err
28+
}
29+
30+
return zpaStudents, nil
31+
}
32+
1233
func (db *DB) GetZPAStudentByMtknr(ctx context.Context, mtknr string) (*model.ZPAStudent, error) {
1334
var zpaStudent model.ZPAStudent
1435

15-
collection := db.Client.Database(db.databaseName).Collection("zpastudents")
36+
collection := db.getCollectionSemester(collectionZpaStudents)
1637

1738
err := collection.FindOne(ctx, bson.D{{Key: "mtknr", Value: mtknr}}).Decode(&zpaStudent)
1839
if err != nil {

0 commit comments

Comments
 (0)