Skip to content

Commit

Permalink
feat: plannedRoomForStudent
Browse files Browse the repository at this point in the history
  • Loading branch information
obcode committed Jan 7, 2025
1 parent 8c799e0 commit d19cf92
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 11 deletions.
174 changes: 174 additions & 0 deletions graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions graph/nta.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions graph/room.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extend type Query {
plannedRoomNames: [String!]
plannedRoomNamesInSlot(day: Int!, time: Int!): [String!]
plannedRoomsInSlot(day: Int!, time: Int!): [PlannedRoom!]
plannedRoomForStudent(ancode: Int!, mtknr: String!): PlannedRoom
}

type Room {
Expand Down
5 changes: 5 additions & 0 deletions graph/room.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions plexams/rooms.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,25 @@ func (p *Plexams) PlannedRoomsInSlot(ctx context.Context, day int, time int) ([]
return rooms, nil
}

func (p *Plexams) PlannedRoomForStudent(ctx context.Context, ancode int, mtknr string) (*model.PlannedRoom, error) {
plannedRoomsForExam, err := p.dbClient.PlannedRoomsForAncode(ctx, ancode)
if err != nil {
log.Error().Err(err).Int("ancode", ancode).Msg("cannot get planned rooms for ancode")
return nil, err
}
for _, room := range plannedRoomsForExam {
for _, student := range room.StudentsInRoom {
if student == mtknr {
return room, nil
}
}
}

err = fmt.Errorf("student %s not found in planned rooms for ancode %d", mtknr, ancode)
log.Error().Err(err).Int("ancode", ancode).Str("mtknr", mtknr).Msg("student not found in planned rooms")
return nil, err
}

// func enhancePlannedRooms(plannedRooms []*model.PlannedRoom) []*model.EnhancedPlannedRoom {
// enhancedPlannedRooms := make([]*model.EnhancedPlannedRoom, 0, len(plannedRooms))
// for _, room := range plannedRooms {
Expand Down

0 comments on commit d19cf92

Please sign in to comment.