Proper checkUp

This commit is contained in:
mr
2026-03-17 15:12:29 +01:00
parent 7fbc077cb1
commit e422efd267
7 changed files with 23 additions and 85 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"net/http"
"oc-scheduler/infrastructure"
"reflect"
"strings"
oclib "cloud.o-forge.io/core/oc-lib"
@@ -160,15 +161,20 @@ func CheckStreamHandler(w http.ResponseWriter, r *http.Request) {
confirmed = true
return
}
infrastructure.CleanupSession(selfID, executionsID, selfID, req)
// Detect whether the user changed dates or instances.
datesChanged := !updated.Start.Equal(ws.Start) ||
changed := updated.Cron != ws.Cron ||
!updated.Start.Equal(ws.Start) ||
updated.DurationS != ws.DurationS ||
(updated.End == nil) != (ws.End == nil) ||
(updated.End != nil && ws.End != nil && !updated.End.Equal(*ws.End))
(updated.End != nil && ws.End != nil && !updated.End.Equal(*ws.End)) ||
updated.BookingMode != ws.BookingMode ||
!reflect.DeepEqual(updated.SelectedBillingStrategy, ws.SelectedBillingStrategy) ||
!reflect.DeepEqual(updated.SelectedInstances, ws.SelectedInstances) ||
!reflect.DeepEqual(updated.SelectedPartnerships, ws.SelectedPartnerships) ||
!reflect.DeepEqual(updated.SelectedBuyings, ws.SelectedBuyings) ||
!reflect.DeepEqual(updated.SelectedStrategies, ws.SelectedStrategies)
infrastructure.CleanupSession(selfID, executionsID, selfID, req)
ws = updated
// Reschedule when dates changed or we haven't scheduled yet.
if err := pushCheck(datesChanged || !scheduled); err != nil {
if err := pushCheck(changed || !scheduled); err != nil {
return
}