[+] bug fix regarding booking-list

This commit is contained in:
mfrigo 2023-11-24 16:27:34 +01:00
parent 4229c13b6b
commit 2274f8d6d0
2 changed files with 8 additions and 10 deletions

View File

@ -101,7 +101,7 @@ func (e Event) Status() int {
func sortByDate(events []Event_Beneficiary) { func sortByDate(events []Event_Beneficiary) {
sort.Slice(events, func(i, j int) bool { sort.Slice(events, func(i, j int) bool {
return events[i].Date().Before(events[j].Date()) return events[i].Date().After(events[j].Date())
}) })
} }
@ -211,6 +211,7 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
} }
events := []agendastorage.Event{} events := []agendastorage.Event{}
currentTime := time.Now().Truncate(24 * time.Hour)
for _, e := range subcriptionresp.Subscription { for _, e := range subcriptionresp.Subscription {
eventresquest := &agenda.GetEventRequest{ eventresquest := &agenda.GetEventRequest{
@ -222,11 +223,8 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
return return
} }
currentTime := time.Now().Truncate(24 * time.Hour)
if eventresp.Event.Enddate.AsTime().Equal(currentTime) || eventresp.Event.Enddate.AsTime().After(currentTime) {
events = append(events, eventresp.Event.ToStorageType()) events = append(events, eventresp.Event.ToStorageType())
} }
}
sort.Sort(sorting.EventsByStartdate(events)) sort.Sort(sorting.EventsByStartdate(events))
@ -251,9 +249,9 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
for _, e := range events { for _, e := range events {
if e.Startdate.After(time.Now()) { if e.Startdate.After(currentTime) {
status_event = 1 status_event = 1
} else if e.Startdate.Before(time.Now()) && e.Enddate.After(time.Now()) { } else if e.Startdate.Before(currentTime) && e.Enddate.After(currentTime) || e.Enddate.Equal(currentTime) {
status_event = 2 status_event = 2
} else { } else {
status_event = 3 status_event = 3
@ -276,7 +274,6 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
var status_booking int var status_booking int
for _, b := range bookings { for _, b := range bookings {
currentTime := time.Now().Truncate(24 * time.Hour)
if b.Enddate.After(currentTime) || b.Enddate.Equal(currentTime) { if b.Enddate.After(currentTime) || b.Enddate.Equal(currentTime) {
GetVehiculeRequest := &fleets.GetVehicleRequest{ GetVehiculeRequest := &fleets.GetVehicleRequest{
Vehicleid: b.Vehicleid, Vehicleid: b.Vehicleid,
@ -289,9 +286,9 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
return return
} }
if b.Startdate.After(time.Now()) { if b.Startdate.After(currentTime) {
status_booking = 1 status_booking = 1
} else if b.Startdate.Before(time.Now()) && b.Enddate.After(time.Now()) { } else if b.Startdate.Before(currentTime) && b.Enddate.After(currentTime) || b.Enddate.Equal(currentTime) {
status_booking = 2 status_booking = 2
} else { } else {
status_booking = 3 status_booking = 3

View File

@ -57,6 +57,7 @@ func (h *ApplicationHandler) VehiclesManagementOverview(w http.ResponseWriter, r
} }
} }
fmt.Println(vehicles_map)
sort.Sort(sorting.VehiclesByLicencePlate(vehicles)) sort.Sort(sorting.VehiclesByLicencePlate(vehicles))
sort.Sort(sorting.BookingsByStartdate(bookings)) sort.Sort(sorting.BookingsByStartdate(bookings))