Skip to content

Commit 5265f60

Browse files
committed
fix: rooms sorted
1 parent 14aa91b commit 5265f60

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

db/rooms.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ func (db *DB) PrePlannedRooms(ctx context.Context) ([]*model.PrePlannedRoom, err
152152
func (db *DB) PrePlannedRoomsForExam(ctx context.Context, ancode int) ([]*model.PrePlannedRoom, error) {
153153
collection := db.getCollectionSemester(collectionRoomsPrePlanned)
154154

155-
cur, err := collection.Find(ctx, bson.M{"ancode": ancode})
155+
findOptions := options.Find()
156+
findOptions.SetSort(bson.D{{Key: "roomname", Value: 1}})
157+
158+
cur, err := collection.Find(ctx, bson.M{"ancode": ancode}, findOptions)
156159
if err != nil {
157160
log.Error().Err(err).Str("collection", collectionRoomsPrePlanned).Msg("MongoDB Find")
158161
return nil, err
@@ -283,7 +286,10 @@ func (db *DB) PlannedRoomsForAncode(ctx context.Context, ancode int) ([]*model.P
283286

284287
filter := bson.M{"ancode": ancode}
285288

286-
cur, err := collection.Find(ctx, filter)
289+
findOptions := options.Find()
290+
findOptions.SetSort(bson.D{{Key: "roomname", Value: 1}})
291+
292+
cur, err := collection.Find(ctx, filter, findOptions)
287293
if err != nil {
288294
log.Error().Err(err).Int("ancode", ancode).Msg("cannot find rooms for ancode")
289295
return nil, err

0 commit comments

Comments
 (0)