diff --git a/config.yaml b/config.yaml index 3dd6ef2..81ecdb5 100644 --- a/config.yaml +++ b/config.yaml @@ -20,12 +20,12 @@ storage: services: grpc: - ip: 10.73.190.200 #192.168.1.25 + ip: 192.168.238.1 #10.73.190.5 enable: true port: 8089 solidarity-api: enable: true - address: 10.73.190.200:9999 #192.168.1.25:9999 + address: 192.168.238.1:9999 #10.73.190.5:9999 routing: type: valhalla diff --git a/handler/services.go b/handler/services.go index 6ae0d67..68b70b9 100644 --- a/handler/services.go +++ b/handler/services.go @@ -46,21 +46,21 @@ func (s *SolidarityServiceHandler) SetPassengerTrip(ctx context.Context, passeng return nil } -func (s *SolidarityServiceHandler) CreateBooking(ctx context.Context, bookingRequest internal.BookingRequest) (passenger internal.Passenger, driver internal.Driver, err error) { +func (s *SolidarityServiceHandler) CreateBooking(ctx context.Context, bookingRequest internal.BookingRequest) ( driver internal.Driver, err error) { //passenger internal.Passenger, bookingRequest.Operator = "internal-grpc" err = s.Storage.CreateBooking(bookingRequest) if err != nil { - return internal.Passenger{}, internal.Driver{}, err - } - passenger, err = s.Storage.GetPassenger(bookingRequest.Passenger_id) - if err != nil { - return internal.Passenger{}, internal.Driver{}, err + return internal.Driver{}, err //internal.Passenger{}, } + // passenger, err = s.Storage.GetPassenger(bookingRequest.Passenger_id) + // if err != nil { + // return internal.Passenger{}, internal.Driver{}, err + // } driver, err = s.Storage.GetDriver(bookingRequest.Driver_id) if err != nil { - return internal.Passenger{}, internal.Driver{}, err + return internal.Driver{}, err //internal.Passenger{}, } - return passenger, driver, nil + return driver, nil //passenger, } func (s *SolidarityServiceHandler) UpdateBooking(ctx context.Context, bookingId string, status internal.BookingStatus) (err error) { diff --git a/servers/grpc/server/services.go b/servers/grpc/server/services.go index 9729e91..4ac3a9f 100644 --- a/servers/grpc/server/services.go +++ b/servers/grpc/server/services.go @@ -245,7 +245,7 @@ func (s *SolidarityServiceServerImpl) CreateBookingSolidarity(ctx context.Contex }, Pickup_date: req.Booking.PickupDate.Seconds, } - passenger, driver, err := s.Handler.CreateBooking(context.Background(), bookingRequest) + driver, err := s.Handler.CreateBooking(context.Background(), bookingRequest) //passenger, if err != nil { if strings.Contains(err.Error(), utils.SQL_DUPLICATE) { err = errors.New("ID is already used") @@ -274,15 +274,8 @@ func (s *SolidarityServiceServerImpl) CreateBookingSolidarity(ctx context.Contex VerifiedIdentity: driver.Driver.VerifiedIdentity, }, Passenger: &proto.User{ - Id: passenger.Passenger.ID, - Alias: passenger.Passenger.Alias, - FirstName: passenger.Passenger.FirstName, - LastName: passenger.Passenger.LastName, - Grade: passenger.Passenger.Grade, - Picture: passenger.Passenger.Picture, - Gender: passenger.Passenger.Gender, - VerifiedIdentity: passenger.Passenger.VerifiedIdentity, - }, + Id: req.Booking.PassengerId, + }, PassengerPickupDate: ×tamp.Timestamp{ Seconds: bookingRequest.Pickup_date, }, @@ -366,13 +359,6 @@ func (s *SolidarityServiceServerImpl) GetBookingSolidarity(ctx context.Context, }, Passenger: &proto.User{ Id: booking.Passenger.ID, - Alias: booking.Passenger.Alias, - FirstName: booking.Passenger.FirstName, - LastName: booking.Passenger.LastName, - Grade: booking.Passenger.Grade, - Picture: booking.Passenger.Picture, - Gender: booking.Passenger.Gender, - VerifiedIdentity: booking.Passenger.VerifiedIdentity, }, PassengerPickupDate: ×tamp.Timestamp{ Seconds: booking.Pickup_date, diff --git a/storage/postgresql.go b/storage/postgresql.go index 1807a04..6efeaeb 100644 --- a/storage/postgresql.go +++ b/storage/postgresql.go @@ -575,13 +575,13 @@ func (s PostgresqlStorage) GetBooking(id string) (booking internal.Booking, err log.Error().Err(err).Msg(errMsg) return internal.Booking{}, errors.New(errMsg + err.Error()) } - passenger, err := s.GetPassenger(booking.Passenger.ID) - if err != nil { - errMsg := "Postgresql Storage GetBooking Error getting passenger" - log.Error().Err(err).Msg(errMsg) - return booking, errors.New(errMsg + err.Error()) - } - booking.Passenger = passenger.Passenger + // passenger, err := s.GetPassenger(booking.Passenger.ID) + // if err != nil { + // errMsg := "Postgresql Storage GetBooking Error getting passenger" + // log.Error().Err(err).Msg(errMsg) + // return booking, errors.New(errMsg + err.Error()) + // } + // booking.Passenger = passenger.Passenger driver, err := s.GetDriver(booking.Driver.ID) if err != nil { errMsg := "Postgresql Storage GetBooking Error getting driver" @@ -677,20 +677,20 @@ func (s PostgresqlStorage) populateBookingDetails(booking internal.Booking, depa errCh := make(chan error, 4) // Buffered channel to handle potential errors // Concurrently fetch passenger information - wg.Add(1) - go func() { - defer wg.Done() + // wg.Add(1) + // go func() { + // defer wg.Done() - passenger, err := s.GetPassenger(booking.Passenger.ID) - if err != nil { - errCh <- fmt.Errorf("Postgresql Storage GetBooking Error getting passenger: %w", err) - return - } + // passenger, err := s.GetPassenger(booking.Passenger.ID) + // if err != nil { + // errCh <- fmt.Errorf("Postgresql Storage GetBooking Error getting passenger: %w", err) + // return + // } - mu.Lock() - booking.Passenger = passenger.Passenger - mu.Unlock() - }() + // mu.Lock() + // booking.Passenger = passenger.Passenger + // mu.Unlock() + // }() // Concurrently fetch driver information wg.Add(1)