créer des resevations avec un compte parcourmob_beneficiaries

This commit is contained in:
Maxime 2024-11-07 18:18:28 +01:00
parent 6bceee5b43
commit f19ecbb2b4
4 changed files with 32 additions and 46 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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: &timestamp.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: &timestamp.Timestamp{
Seconds: booking.Pickup_date,

View File

@ -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)