[+] bug fix regarding booking-list
This commit is contained in:
parent
4229c13b6b
commit
2274f8d6d0
|
@ -101,7 +101,7 @@ func (e Event) Status() int {
|
|||
|
||||
func sortByDate(events []Event_Beneficiary) {
|
||||
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{}
|
||||
currentTime := time.Now().Truncate(24 * time.Hour)
|
||||
|
||||
for _, e := range subcriptionresp.Subscription {
|
||||
eventresquest := &agenda.GetEventRequest{
|
||||
|
@ -222,10 +223,7 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||
w.WriteHeader(http.StatusInternalServerError)
|
||||
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))
|
||||
|
@ -251,9 +249,9 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||
|
||||
for _, e := range events {
|
||||
|
||||
if e.Startdate.After(time.Now()) {
|
||||
if e.Startdate.After(currentTime) {
|
||||
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
|
||||
} else {
|
||||
status_event = 3
|
||||
|
@ -276,7 +274,6 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||
var status_booking int
|
||||
for _, b := range bookings {
|
||||
|
||||
currentTime := time.Now().Truncate(24 * time.Hour)
|
||||
if b.Enddate.After(currentTime) || b.Enddate.Equal(currentTime) {
|
||||
GetVehiculeRequest := &fleets.GetVehicleRequest{
|
||||
Vehicleid: b.Vehicleid,
|
||||
|
@ -289,9 +286,9 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||
return
|
||||
}
|
||||
|
||||
if b.Startdate.After(time.Now()) {
|
||||
if b.Startdate.After(currentTime) {
|
||||
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
|
||||
} else {
|
||||
status_booking = 3
|
||||
|
|
|
@ -57,6 +57,7 @@ func (h *ApplicationHandler) VehiclesManagementOverview(w http.ResponseWriter, r
|
|||
|
||||
}
|
||||
}
|
||||
fmt.Println(vehicles_map)
|
||||
|
||||
sort.Sort(sorting.VehiclesByLicencePlate(vehicles))
|
||||
sort.Sort(sorting.BookingsByStartdate(bookings))
|
||||
|
|
Loading…
Reference in New Issue