From 47e0aba41a08662c4488bc5797faec2e12fdfb89 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Mon, 11 Sep 2023 14:11:47 +0200 Subject: [PATCH] removed the `SearchRooms` endpoint --- server/backend/rpcserver.go | 43 ------------------------------------- 1 file changed, 43 deletions(-) diff --git a/server/backend/rpcserver.go b/server/backend/rpcserver.go index 0a4b6d00..28554723 100644 --- a/server/backend/rpcserver.go +++ b/server/backend/rpcserver.go @@ -102,49 +102,6 @@ func (s *CampusServer) GetNewsSources(ctx context.Context, _ *emptypb.Empty) (ne return &pb.NewsSourceArray{Sources: resp}, nil } -// SearchRooms returns all rooms that match the given search query. -func (s *CampusServer) SearchRooms(ctx context.Context, req *pb.SearchRoomsRequest) (*pb.SearchRoomsReply, error) { - if err := s.checkDevice(ctx); err != nil { - return nil, err - } - if req.Query == "" { - return &pb.SearchRoomsReply{Rooms: make([]*pb.Room, 0)}, nil - } - var res []struct { // struct to scan database query into - model.RoomfinderRooms - Campus string - Name string - } - err := s.db.Raw("SELECT r.*, a.campus, a.name "+ - "FROM roomfinder_rooms r "+ - "LEFT JOIN roomfinder_building2area a ON a.building_nr = r.building_nr "+ - "WHERE MATCH(room_code, info, address) AGAINST(?)", req.Query).Scan(&res).Error - if errors.Is(err, gorm.ErrRecordNotFound) { - return &pb.SearchRoomsReply{Rooms: make([]*pb.Room, 0)}, nil - } - if err != nil { - log.WithError(err).Error("failed to search rooms") - return nil, status.Error(codes.Internal, err.Error()) - } - response := &pb.SearchRoomsReply{ - Rooms: make([]*pb.Room, len(res)), - } - for i, row := range res { - response.Rooms[i] = &pb.Room{ - RoomId: row.RoomID, - RoomCode: row.RoomCode.String, - BuildingNr: row.BuildingNr.String, - ArchId: row.ArchID.String, - Info: row.Info.String, - Address: row.Address.String, - Purpose: row.Purpose.String, - Campus: row.Campus, - Name: row.Name, - } - } - return response, nil -} - func (s *CampusServer) GetTopNews(ctx context.Context, _ *emptypb.Empty) (*pb.GetTopNewsReply, error) { if err := s.checkDevice(ctx); err != nil { return nil, err