This commit is contained in:
mr
2024-11-28 13:19:01 +01:00
parent b388e43f30
commit 9ea342c4c4
37 changed files with 198 additions and 122 deletions

View File

@@ -26,7 +26,7 @@ func (wfa *Booking) CheckBooking(id string, start time.Time, end *time.Time) (bo
return true, nil
}
e := *end
accessor := New()
accessor := New(tools.BOOKING, "", nil, nil)
res, code, err := accessor.Search(&dbs.Filters{
And: map[string][]dbs.Filter{ // check if there is a booking on the same compute resource by filtering on the compute_resource_id, the state and the execution date
"compute_resource_id": {{Operator: dbs.EQUAL.String(), Value: id}},
@@ -54,7 +54,5 @@ func (d *Booking) GetName() string {
}
func (d *Booking) GetAccessor(peerID string, groups []string, caller *tools.HTTPCaller) utils.Accessor {
data := New() // Create a new instance of the accessor
data.Init(tools.BOOKING, peerID, groups, caller) // Initialize the accessor with the BOOKING model type
return data
return New(tools.BOOKING, peerID, groups, caller) // Create a new instance of the accessor
}

View File

@@ -5,8 +5,10 @@ import (
"cloud.o-forge.io/core/oc-lib/dbs"
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
"cloud.o-forge.io/core/oc-lib/logs"
"cloud.o-forge.io/core/oc-lib/models/utils"
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
"cloud.o-forge.io/core/oc-lib/tools"
)
type bookingMongoAccessor struct {
@@ -14,8 +16,16 @@ type bookingMongoAccessor struct {
}
// New creates a new instance of the bookingMongoAccessor
func New() *bookingMongoAccessor {
return &bookingMongoAccessor{}
func New(t tools.DataType, peerID string, groups []string, caller *tools.HTTPCaller) *bookingMongoAccessor {
return &bookingMongoAccessor{
AbstractAccessor: utils.AbstractAccessor{
Logger: logs.CreateLogger(t.String()), // Create a logger with the data type
Caller: caller,
PeerID: peerID,
Groups: groups, // Set the caller
Type: t.String(),
},
}
}
/*