fix: update history count

This commit is contained in:
Arnaud Delcasse
2026-02-25 10:05:07 +01:00
parent b5e722ff9b
commit 1b1c4443fc
7 changed files with 71 additions and 13 deletions

View File

@@ -9,6 +9,7 @@ import (
"strings"
"time"
coreapplication "git.coopgo.io/coopgo-apps/parcoursmob/core/application"
"git.coopgo.io/coopgo-apps/parcoursmob/core/utils/identification"
groupstorage "git.coopgo.io/coopgo-platform/groups-management/storage"
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
@@ -614,12 +615,17 @@ func (h *Handler) SolidarityTransportBookingDisplayHTTPHandler() http.HandlerFun
var replacementDriversMap map[string]mobilityaccountsstorage.Account
var replacementPricing map[string]map[string]interface{}
var replacementLocations map[string]string
var driverLastTrips map[string]time.Time
var lastTripDays int
if result.Booking.Status == "CANCELLED" {
// Initialize maps to avoid nil pointer in template
replacementDriversMap = make(map[string]mobilityaccountsstorage.Account)
replacementPricing = make(map[string]map[string]interface{})
replacementLocations = make(map[string]string)
driverLastTrips = make(map[string]time.Time)
// Preserve the original booking's noreturn status when searching for replacement drivers
noreturn := result.Booking.Journey.Noreturn
searchResult, err := h.applicationHandler.SearchJourneys(
r.Context(),
result.Booking.Journey.PassengerPickupDate,
@@ -628,11 +634,15 @@ func (h *Handler) SolidarityTransportBookingDisplayHTTPHandler() http.HandlerFun
result.Booking.PassengerId,
result.Booking.DriverId, // Exclude the original driver
result.Booking.GroupId, // Exclude drivers with bookings in this group
nil, // options - use defaults
&coreapplication.SearchJourneyOptions{
SolidarityTransportNoreturn: &noreturn,
},
)
if err == nil {
replacementDrivers = searchResult.DriverJourneys
replacementDriversMap = searchResult.Drivers
driverLastTrips = searchResult.DriverLastTrips
lastTripDays = searchResult.LastTripDays
// Calculate pricing for each replacement driver journey
for _, dj := range searchResult.DriverJourneys {
@@ -668,7 +678,7 @@ func (h *Handler) SolidarityTransportBookingDisplayHTTPHandler() http.HandlerFun
}
}
h.renderer.SolidarityTransportBookingDisplay(w, r, result.Booking, result.Driver, result.Passenger, result.PassengerWalletBalance, replacementDrivers, replacementDriversMap, replacementPricing, replacementLocations)
h.renderer.SolidarityTransportBookingDisplay(w, r, result.Booking, result.Driver, result.Passenger, result.PassengerWalletBalance, replacementDrivers, replacementDriversMap, replacementPricing, replacementLocations, driverLastTrips, lastTripDays)
}
}