Add public theme
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 2m52s
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 2m52s
This commit is contained in:
@@ -77,14 +77,14 @@ func (h *ApplicationHandler) GetAdministrationData(ctx context.Context) (*Admini
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
accounts, accountsErr = h.services.GetAccounts()
|
||||
accounts, accountsErr = h.services.GetAccounts(ctx)
|
||||
}()
|
||||
|
||||
// Retrieve beneficiaries in a goroutine
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
beneficiaries, beneficiariesErr = h.services.GetBeneficiaries()
|
||||
beneficiaries, beneficiariesErr = h.services.GetBeneficiaries(ctx)
|
||||
}()
|
||||
|
||||
// Retrieve bookings in a goroutine
|
||||
@@ -570,8 +570,8 @@ func (h *ApplicationHandler) GetBookingsStats(status, startDate, endDate string)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) GetBeneficiariesStats() (*AdminBeneficiariesStatsResult, error) {
|
||||
beneficiaries, err := h.services.GetBeneficiaries()
|
||||
func (h *ApplicationHandler) GetBeneficiariesStats(ctx context.Context) (*AdminBeneficiariesStatsResult, error) {
|
||||
beneficiaries, err := h.services.GetBeneficiaries(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ func (h *ApplicationHandler) DisplayGroupModule(ctx context.Context, groupID str
|
||||
h.cache.PutWithTTL(cacheID, accounts, 1*time.Hour)
|
||||
|
||||
// Get beneficiaries in current user's group
|
||||
accountsBeneficiaire, err := h.services.GetBeneficiariesInGroup(currentUserGroup)
|
||||
accountsBeneficiaire, err := h.services.GetBeneficiariesInGroup(ctx, currentUserGroup)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get beneficiaries in group: %w", err)
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ func (h *ApplicationHandler) SearchJourneys(
|
||||
|
||||
// SOLIDARITY TRANSPORT
|
||||
var err error
|
||||
drivers, err = h.services.GetAccountsInNamespacesMap([]string{"solidarity_drivers", "organized_carpool_drivers"})
|
||||
drivers, err = h.services.GetAccountsInNamespacesMap(ctx, []string{"solidarity_drivers", "organized_carpool_drivers"})
|
||||
if err != nil {
|
||||
drivers = map[string]mobilityaccountsstorage.Account{}
|
||||
}
|
||||
@@ -99,30 +99,20 @@ func (h *ApplicationHandler) SearchJourneys(
|
||||
protodep, _ := transformers.GeoJsonToProto(departureGeo)
|
||||
protodest, _ := transformers.GeoJsonToProto(destinationGeo)
|
||||
|
||||
// Get driver IDs to exclude based on group_id (drivers who already have bookings in this group)
|
||||
excludedDriverIds := make(map[string]bool)
|
||||
if solidarityExcludeGroupId != "" {
|
||||
bookingsResp, err := h.services.GRPC.SolidarityTransport.GetSolidarityTransportBookings(ctx, &gen.GetSolidarityTransportBookingsRequest{
|
||||
StartDate: timestamppb.New(time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)),
|
||||
EndDate: timestamppb.New(time.Date(9999, 12, 31, 0, 0, 0, 0, time.UTC)),
|
||||
})
|
||||
if err == nil {
|
||||
for _, booking := range bookingsResp.Bookings {
|
||||
if booking.GroupId == solidarityExcludeGroupId {
|
||||
excludedDriverIds[booking.DriverId] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if solidarityTransportEnabled {
|
||||
log.Debug().Time("departure time", departureDateTime).Msg("calling driver journeys with ...")
|
||||
|
||||
res, err := h.services.GRPC.SolidarityTransport.GetDriverJourneys(ctx, &gen.GetDriverJourneysRequest{
|
||||
req := &gen.GetDriverJourneysRequest{
|
||||
Departure: protodep,
|
||||
Arrival: protodest,
|
||||
DepartureDate: timestamppb.New(departureDateTime),
|
||||
})
|
||||
}
|
||||
// Pass exclude_group_id to the service to filter out drivers with bookings in this group
|
||||
if solidarityExcludeGroupId != "" {
|
||||
req.ExcludeGroupId = &solidarityExcludeGroupId
|
||||
}
|
||||
|
||||
res, err := h.services.GRPC.SolidarityTransport.GetDriverJourneys(ctx, req)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("error in grpc call to GetDriverJourneys")
|
||||
} else {
|
||||
@@ -138,10 +128,6 @@ func (h *ApplicationHandler) SearchJourneys(
|
||||
if dj.DriverId == solidarityTransportExcludeDriver {
|
||||
continue
|
||||
}
|
||||
// Skip drivers who already have bookings in the same group
|
||||
if excludedDriverIds[dj.DriverId] {
|
||||
continue
|
||||
}
|
||||
if !yield(dj) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ type MembersResult struct {
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) GetMembers(ctx context.Context) (*MembersResult, error) {
|
||||
accounts, err := h.services.GetAccounts()
|
||||
accounts, err := h.services.GetAccounts(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ func (h *ApplicationHandler) GetOrganizedCarpoolOverview(ctx context.Context, st
|
||||
}
|
||||
}
|
||||
|
||||
beneficiariesMap, err := h.services.GetBeneficiariesMap()
|
||||
beneficiariesMap, err := h.services.GetBeneficiariesMap(ctx)
|
||||
if err != nil {
|
||||
beneficiariesMap = map[string]mobilityaccountsstorage.Account{}
|
||||
}
|
||||
@@ -403,12 +403,12 @@ func (h *ApplicationHandler) GetOrganizedCarpoolBookingData(ctx context.Context,
|
||||
return nil, fmt.Errorf("carpool booking not found")
|
||||
}
|
||||
|
||||
driver, err := h.services.GetAccount(resp.Booking.Driver.Id)
|
||||
driver, err := h.services.GetAccount(ctx, resp.Booking.Driver.Id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("driver retrieval issue: %w", err)
|
||||
}
|
||||
|
||||
passenger, err := h.services.GetAccount(resp.Booking.Passenger.Id)
|
||||
passenger, err := h.services.GetAccount(ctx, resp.Booking.Passenger.Id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("passenger retrieval issue: %w", err)
|
||||
}
|
||||
@@ -585,7 +585,7 @@ type OrganizedCarpoolDriverDataResult struct {
|
||||
func (h *ApplicationHandler) GetOrganizedCarpoolDriverData(ctx context.Context, driverID string) (*OrganizedCarpoolDriverDataResult, error) {
|
||||
documents := h.filestorage.List(filestorage.PREFIX_ORGANIZED_CARPOOL_DRIVERS + "/" + driverID)
|
||||
|
||||
driver, err := h.services.GetAccount(driverID)
|
||||
driver, err := h.services.GetAccount(ctx, driverID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("issue retrieving driver account: %w", err)
|
||||
}
|
||||
@@ -686,7 +686,7 @@ type OrganizedCarpoolDriverResult struct {
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) GetOrganizedCarpoolDriver(ctx context.Context, driverID string) (*OrganizedCarpoolDriverResult, error) {
|
||||
driver, err := h.services.GetAccount(driverID)
|
||||
driver, err := h.services.GetAccount(ctx, driverID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("issue retrieving driver account: %w", err)
|
||||
}
|
||||
@@ -703,7 +703,7 @@ func (h *ApplicationHandler) GetOrganizedCarpoolDriver(ctx context.Context, driv
|
||||
|
||||
func (h *ApplicationHandler) UpdateOrganizedCarpoolDriver(ctx context.Context, driverID, firstName, lastName, email string, birthdate *time.Time, phoneNumber, fileNumber string, address, addressDestination any, gender, otherProperties string) (string, error) {
|
||||
// Security check: verify the account exists and is an organized carpool driver
|
||||
driver, err := h.services.GetAccount(driverID)
|
||||
driver, err := h.services.GetAccount(ctx, driverID)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("issue retrieving driver account: %w", err)
|
||||
}
|
||||
@@ -786,7 +786,7 @@ func (h *ApplicationHandler) UpdateOrganizedCarpoolDriver(ctx context.Context, d
|
||||
|
||||
func (h *ApplicationHandler) ArchiveOrganizedCarpoolDriver(ctx context.Context, driverID string) error {
|
||||
// Security check: verify the account exists and is an organized carpool driver
|
||||
driver, err := h.services.GetAccount(driverID)
|
||||
driver, err := h.services.GetAccount(ctx, driverID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("issue retrieving driver account: %w", err)
|
||||
}
|
||||
@@ -815,7 +815,7 @@ func (h *ApplicationHandler) ArchiveOrganizedCarpoolDriver(ctx context.Context,
|
||||
|
||||
func (h *ApplicationHandler) UnarchiveOrganizedCarpoolDriver(ctx context.Context, driverID string) error {
|
||||
// Security check: verify the account exists and is an organized carpool driver
|
||||
driver, err := h.services.GetAccount(driverID)
|
||||
driver, err := h.services.GetAccount(ctx, driverID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("issue retrieving driver account: %w", err)
|
||||
}
|
||||
@@ -844,7 +844,7 @@ func (h *ApplicationHandler) UnarchiveOrganizedCarpoolDriver(ctx context.Context
|
||||
|
||||
func (h *ApplicationHandler) AddOrganizedCarpoolDriverDocument(ctx context.Context, driverID string, file io.Reader, filename string, fileSize int64, documentType, documentName string) error {
|
||||
// Security check: verify the account exists and is an organized carpool driver
|
||||
driver, err := h.services.GetAccount(driverID)
|
||||
driver, err := h.services.GetAccount(ctx, driverID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("issue retrieving driver account: %w", err)
|
||||
}
|
||||
@@ -876,7 +876,7 @@ func (h *ApplicationHandler) DeleteOrganizedCarpoolDriverDocument(ctx context.Co
|
||||
|
||||
func (h *ApplicationHandler) AddOrganizedCarpoolTrip(ctx context.Context, driverID, outwardtime, returntime string, departure, destination *geojson.Feature, days map[string]bool) error {
|
||||
// Security check: verify the account exists and is an organized carpool driver
|
||||
driver, err := h.services.GetAccount(driverID)
|
||||
driver, err := h.services.GetAccount(ctx, driverID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("issue retrieving driver account: %w", err)
|
||||
}
|
||||
@@ -911,14 +911,18 @@ func (h *ApplicationHandler) AddOrganizedCarpoolTrip(ctx context.Context, driver
|
||||
for day, enabled := range days {
|
||||
if enabled {
|
||||
dayCode := dayMap[day]
|
||||
outwardschedules = append(outwardschedules, map[string]any{
|
||||
"day": dayCode,
|
||||
"time_of_day": outwardtime,
|
||||
})
|
||||
returnschedules = append(returnschedules, map[string]any{
|
||||
"day": dayCode,
|
||||
"time_of_day": returntime,
|
||||
})
|
||||
if outwardtime != "" {
|
||||
outwardschedules = append(outwardschedules, map[string]any{
|
||||
"day": dayCode,
|
||||
"time_of_day": outwardtime,
|
||||
})
|
||||
}
|
||||
if returntime != "" {
|
||||
returnschedules = append(returnschedules, map[string]any{
|
||||
"day": dayCode,
|
||||
"time_of_day": returntime,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -962,12 +966,24 @@ func (h *ApplicationHandler) AddOrganizedCarpoolTrip(ctx context.Context, driver
|
||||
return fmt.Errorf("failed marshaling return geojson: %w", err)
|
||||
}
|
||||
|
||||
trips = append(trips, &proto.CarpoolFeatureCollection{
|
||||
Serialized: string(outwardtrip),
|
||||
})
|
||||
trips = append(trips, &proto.CarpoolFeatureCollection{
|
||||
Serialized: string(returntrip),
|
||||
})
|
||||
// Only add outward trip if outward time is provided
|
||||
if outwardtime != "" {
|
||||
trips = append(trips, &proto.CarpoolFeatureCollection{
|
||||
Serialized: string(outwardtrip),
|
||||
})
|
||||
}
|
||||
|
||||
// Only add return trip if return time is provided
|
||||
if returntime != "" {
|
||||
trips = append(trips, &proto.CarpoolFeatureCollection{
|
||||
Serialized: string(returntrip),
|
||||
})
|
||||
}
|
||||
|
||||
// If no trips to create, return early
|
||||
if len(trips) == 0 {
|
||||
return fmt.Errorf("at least one time (outward or return) must be provided")
|
||||
}
|
||||
|
||||
req := &proto.CreateRegularRoutesRequest{
|
||||
Routes: trips,
|
||||
@@ -1016,21 +1032,21 @@ func (h *ApplicationHandler) GetOrganizedCarpoolJourneyData(ctx context.Context,
|
||||
return nil, fmt.Errorf("could not unmarshal carpool journey: %w", err)
|
||||
}
|
||||
|
||||
driver, err := h.services.GetAccount(driverID)
|
||||
driver, err := h.services.GetAccount(ctx, driverID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get driver: %w", err)
|
||||
}
|
||||
|
||||
var passenger mobilityaccountsstorage.Account
|
||||
if passengerID != "" {
|
||||
passenger, err = h.services.GetAccount(passengerID)
|
||||
passenger, err = h.services.GetAccount(ctx, passengerID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get passenger account: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Get beneficiaries in current user's group
|
||||
beneficiaries, err := h.services.GetBeneficiariesInGroup(currentUserGroup)
|
||||
beneficiaries, err := h.services.GetBeneficiariesInGroup(ctx, currentUserGroup)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get beneficiaries: %w", err)
|
||||
}
|
||||
@@ -1192,7 +1208,7 @@ func (h *ApplicationHandler) CreateOrganizedCarpoolJourneyBooking(ctx context.Co
|
||||
// Get passenger account and calculate pricing
|
||||
var passenger mobilityaccountsstorage.Account
|
||||
if passengerID != "" {
|
||||
passenger, err = h.services.GetAccount(passengerID)
|
||||
passenger, err = h.services.GetAccount(ctx, passengerID)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not get passenger account: %w", err)
|
||||
}
|
||||
@@ -1268,7 +1284,7 @@ func (h *ApplicationHandler) CreateOrganizedCarpoolJourneyBooking(ctx context.Co
|
||||
if message != "" && !doNotSend {
|
||||
send_message := strings.ReplaceAll(message, "{booking_id}", bookingRes.Booking.Id)
|
||||
log.Debug().Str("message", send_message).Msg("Carpool booking created: sending message")
|
||||
h.GenerateSMS(driverID, send_message)
|
||||
h.GenerateSMS(ctx, driverID, send_message)
|
||||
}
|
||||
|
||||
return bookingRes.Booking.Id, nil
|
||||
@@ -1403,7 +1419,7 @@ func (h *ApplicationHandler) GetOrganizedCarpoolBookings(ctx context.Context, st
|
||||
}
|
||||
|
||||
// Get beneficiaries
|
||||
beneficiariesMap, err := h.services.GetBeneficiariesMap()
|
||||
beneficiariesMap, err := h.services.GetBeneficiariesMap(ctx)
|
||||
if err != nil {
|
||||
beneficiariesMap = map[string]mobilityaccountsstorage.Account{}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
)
|
||||
|
||||
func (h *ApplicationHandler) SendSMS(ctx context.Context, beneficiaryID, message string) error {
|
||||
return h.GenerateSMS(beneficiaryID, message)
|
||||
return h.GenerateSMS(ctx, beneficiaryID, message)
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) GenerateSMS(recipientid string, message string) error {
|
||||
recipient, err := h.services.GetAccount(recipientid)
|
||||
func (h *ApplicationHandler) GenerateSMS(ctx context.Context, recipientid string, message string) error {
|
||||
recipient, err := h.services.GetAccount(ctx, recipientid)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("user not found")
|
||||
return err
|
||||
|
||||
@@ -183,7 +183,7 @@ func filterBookingsByGeography(bookings []*solidaritytypes.Booking, departurePol
|
||||
|
||||
func (h *ApplicationHandler) GetSolidarityTransportOverview(ctx context.Context, status, driverID, startDate, endDate, departureGeoLayer, departureGeoCode, destinationGeoLayer, destinationGeoCode, passengerAddressGeoLayer, passengerAddressGeoCode, histStatus, histDriverID, histStartDate, histEndDate, histDepartureGeoLayer, histDepartureGeoCode, histDestinationGeoLayer, histDestinationGeoCode, histPassengerAddressGeoLayer, histPassengerAddressGeoCode string, archivedFilter bool, driverAddressGeoLayer, driverAddressGeoCode string) (*SolidarityTransportOverviewResult, error) {
|
||||
// Get ALL drivers for the accountsMap (used in bookings display)
|
||||
allDrivers, err := h.solidarityDrivers("", false)
|
||||
allDrivers, err := h.solidarityDrivers(ctx, "", false)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("issue getting all solidarity drivers")
|
||||
allDrivers = []mobilityaccountsstorage.Account{}
|
||||
@@ -196,7 +196,7 @@ func (h *ApplicationHandler) GetSolidarityTransportOverview(ctx context.Context,
|
||||
}
|
||||
|
||||
// Get filtered drivers for the drivers tab display
|
||||
accounts, err := h.solidarityDrivers("", archivedFilter)
|
||||
accounts, err := h.solidarityDrivers(ctx, "", archivedFilter)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("issue getting solidarity drivers")
|
||||
accounts = []mobilityaccountsstorage.Account{}
|
||||
@@ -241,7 +241,7 @@ func (h *ApplicationHandler) GetSolidarityTransportOverview(ctx context.Context,
|
||||
return strings.Compare(firstNameA, firstNameB)
|
||||
})
|
||||
|
||||
beneficiariesMap, err := h.services.GetBeneficiariesMap()
|
||||
beneficiariesMap, err := h.services.GetBeneficiariesMap(ctx)
|
||||
if err != nil {
|
||||
beneficiariesMap = map[string]mobilityaccountsstorage.Account{}
|
||||
}
|
||||
@@ -435,7 +435,7 @@ type SolidarityTransportBookingsResult struct {
|
||||
|
||||
func (h *ApplicationHandler) GetSolidarityTransportBookings(ctx context.Context, startDate, endDate *time.Time, status, driverID, departureGeoLayer, departureGeoCode, destinationGeoLayer, destinationGeoCode, passengerAddressGeoLayer, passengerAddressGeoCode string) (*SolidarityTransportBookingsResult, error) {
|
||||
// Get all drivers
|
||||
drivers, err := h.solidarityDrivers("", false)
|
||||
drivers, err := h.solidarityDrivers(ctx, "", false)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("issue getting solidarity drivers")
|
||||
drivers = []mobilityaccountsstorage.Account{}
|
||||
@@ -447,7 +447,7 @@ func (h *ApplicationHandler) GetSolidarityTransportBookings(ctx context.Context,
|
||||
}
|
||||
|
||||
// Get beneficiaries
|
||||
beneficiariesMap, err := h.services.GetBeneficiariesMap()
|
||||
beneficiariesMap, err := h.services.GetBeneficiariesMap(ctx)
|
||||
if err != nil {
|
||||
beneficiariesMap = map[string]mobilityaccountsstorage.Account{}
|
||||
}
|
||||
@@ -1030,7 +1030,7 @@ func (h *ApplicationHandler) GetSolidarityTransportJourneyData(ctx context.Conte
|
||||
// Get passenger account
|
||||
var passenger mobilityaccountsstorage.Account
|
||||
if passengerID != "" {
|
||||
passengerResp, err := h.services.GetAccount(passengerID)
|
||||
passengerResp, err := h.services.GetAccount(ctx, passengerID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get passenger account: %w", err)
|
||||
}
|
||||
@@ -1048,7 +1048,7 @@ func (h *ApplicationHandler) GetSolidarityTransportJourneyData(ctx context.Conte
|
||||
}
|
||||
|
||||
// Get beneficiaries in current user's group
|
||||
beneficiaries, err := h.services.GetBeneficiariesInGroup(currentUserGroup)
|
||||
beneficiaries, err := h.services.GetBeneficiariesInGroup(ctx, currentUserGroup)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get beneficiaries: %w", err)
|
||||
}
|
||||
@@ -1093,7 +1093,7 @@ func (h *ApplicationHandler) CreateSolidarityTransportJourneyBooking(ctx context
|
||||
// Get passenger account for pricing
|
||||
var passenger mobilityaccountsstorage.Account
|
||||
if passengerID != "" {
|
||||
passengerResp, err := h.services.GetAccount(passengerID)
|
||||
passengerResp, err := h.services.GetAccount(ctx, passengerID)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not get passenger account: %w", err)
|
||||
}
|
||||
@@ -1171,7 +1171,7 @@ func (h *ApplicationHandler) CreateSolidarityTransportJourneyBooking(ctx context
|
||||
// Send SMS if not disabled
|
||||
if !doNotSend && message != "" {
|
||||
send_message := strings.ReplaceAll(message, "{booking_id}", resp.Booking.Id)
|
||||
if err := h.GenerateSMS(driverID, send_message); err != nil {
|
||||
if err := h.GenerateSMS(ctx, driverID, send_message); err != nil {
|
||||
log.Error().Err(err).Msg("failed to send SMS")
|
||||
}
|
||||
}
|
||||
@@ -1248,12 +1248,12 @@ func (h *ApplicationHandler) GetSolidarityTransportBookingData(ctx context.Conte
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) solidarityDrivers(searchFilter string, archivedFilter bool) ([]mobilityaccountsstorage.Account, error) {
|
||||
func (h *ApplicationHandler) solidarityDrivers(ctx context.Context, searchFilter string, archivedFilter bool) ([]mobilityaccountsstorage.Account, error) {
|
||||
request := &mobilityaccounts.GetAccountsRequest{
|
||||
Namespaces: []string{"solidarity_drivers"},
|
||||
}
|
||||
|
||||
resp, err := h.services.GRPC.MobilityAccounts.GetAccounts(context.TODO(), request)
|
||||
resp, err := h.services.GRPC.MobilityAccounts.GetAccounts(ctx, request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1320,7 +1320,7 @@ func (h *ApplicationHandler) CalculateSolidarityTransportPricing(ctx context.Con
|
||||
// Get passenger account
|
||||
var passenger mobilityaccountsstorage.Account
|
||||
if passengerID != "" {
|
||||
passengerResp, err := h.services.GetAccount(passengerID)
|
||||
passengerResp, err := h.services.GetAccount(ctx, passengerID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get passenger account: %w", err)
|
||||
}
|
||||
@@ -1376,6 +1376,17 @@ func (h *ApplicationHandler) calculateSolidarityTransportPricing(ctx context.Con
|
||||
}
|
||||
}
|
||||
}
|
||||
if pst, ok := op_map["previous_solidarity_transport_count"]; ok {
|
||||
if pst_str, ok := pst.(string); ok {
|
||||
if pst_str != "" {
|
||||
if n, err := strconv.Atoi(pst_str); err == nil {
|
||||
history = history + n
|
||||
} else {
|
||||
log.Error().Err(err).Str("n", pst_str).Msg("string to int conversion error")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1459,7 +1470,7 @@ func (h *ApplicationHandler) UpdateSolidarityTransportBookingStatus(ctx context.
|
||||
if previousStatus != "VALIDATED" && status == "VALIDATED" {
|
||||
if message != "" {
|
||||
send_message := strings.ReplaceAll(message, "{booking_id}", bookingID)
|
||||
h.GenerateSMS(passenger.ID, send_message)
|
||||
h.GenerateSMS(ctx, passenger.ID, send_message)
|
||||
}
|
||||
if err := h.CreditWallet(ctx, passenger.ID, -1*booking.Journey.Price.Amount, "Transport solidaire", "Débit transport solidaire"); err != nil {
|
||||
return fmt.Errorf("could not debit passenger wallet: %w", err)
|
||||
@@ -1467,6 +1478,32 @@ func (h *ApplicationHandler) UpdateSolidarityTransportBookingStatus(ctx context.
|
||||
if err := h.CreditWallet(ctx, driver.ID, booking.DriverCompensationAmount, "Transport solidaire", "Crédit transport solidaire"); err != nil {
|
||||
return fmt.Errorf("could not credit driver wallet: %w", err)
|
||||
}
|
||||
|
||||
if notify {
|
||||
groupsrequest := &groupsmanagement.GetGroupsRequest{
|
||||
Namespaces: []string{"parcoursmob_organizations"},
|
||||
Member: booking.PassengerId,
|
||||
}
|
||||
|
||||
groupsresp, err := h.services.GRPC.GroupsManagement.GetGroups(ctx, groupsrequest)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("")
|
||||
} else if len(groupsresp.Groups) > 0 {
|
||||
members, _, err := h.groupmembers(groupsresp.Groups[0].Id)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("could not retrieve groupe members")
|
||||
} else {
|
||||
for _, m := range members {
|
||||
if email, ok := m.Data["email"].(string); ok {
|
||||
h.emailing.Send("solidarity_transport.booking_driver_accept", email, map[string]string{
|
||||
"bookingid": booking.Id,
|
||||
"baseUrl": h.config.GetString("base_url"),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Credit passenger / debit driver when previous status was VALIDATED and new status is not VALIDATED anymore
|
||||
|
||||
@@ -62,7 +62,7 @@ func (h *ApplicationHandler) GetVehiclesManagementOverview(ctx context.Context,
|
||||
}
|
||||
}
|
||||
|
||||
driversMap, _ := h.services.GetBeneficiariesMap()
|
||||
driversMap, _ := h.services.GetBeneficiariesMap(ctx)
|
||||
|
||||
sort.Sort(sorting.VehiclesByLicencePlate(vehicles))
|
||||
sort.Sort(sorting.BookingsByStartdate(bookings))
|
||||
@@ -180,7 +180,7 @@ func (h *ApplicationHandler) GetVehiclesManagementBookingsList(ctx context.Conte
|
||||
cacheID := uuid.NewString()
|
||||
h.cache.PutWithTTL(cacheID, bookings, 1*time.Hour)
|
||||
|
||||
driversMap, _ := h.services.GetBeneficiariesMap()
|
||||
driversMap, _ := h.services.GetBeneficiariesMap(ctx)
|
||||
|
||||
return &VehiclesManagementBookingsListResult{
|
||||
VehiclesMap: vehiclesMap,
|
||||
@@ -263,7 +263,7 @@ func (h *ApplicationHandler) GetVehicleDisplay(ctx context.Context, vehicleID st
|
||||
return nil, fmt.Errorf("failed to get vehicle: %w", err)
|
||||
}
|
||||
|
||||
beneficiaries, err := h.services.GetBeneficiariesMap()
|
||||
beneficiaries, err := h.services.GetBeneficiariesMap(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get beneficiaries: %w", err)
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ func (h *ApplicationHandler) SearchVehicles(ctx context.Context, beneficiaryID s
|
||||
beneficiarydocuments = h.filestorage.List(filestorage.PREFIX_BENEFICIARIES + "/" + beneficiary.ID)
|
||||
}
|
||||
|
||||
accounts, err := h.services.GetBeneficiariesMap()
|
||||
accounts, err := h.services.GetBeneficiariesMap(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get beneficiaries: %w", err)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func (h *ApplicationHandler) CreditWallet(ctx context.Context, userid string, amount float64, paymentMethod string, description string) error {
|
||||
account, err := h.services.GetAccount(userid)
|
||||
account, err := h.services.GetAccount(ctx, userid)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("could not retrieve account")
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user