correction on bookig flow

This commit is contained in:
mr
2026-01-15 13:27:57 +01:00
parent 7c5d5c491f
commit 1c3b9218f7
3 changed files with 9 additions and 7 deletions

View File

@@ -194,7 +194,7 @@ AccessPricingProfile ^-- ProcessingResourcePricingProfile
ExploitPricingProfile ^-- ComputeResourcePricingProfile ExploitPricingProfile ^-- ComputeResourcePricingProfile
ExploitPricingProfile ^-- StorageResourcePricingProfile ExploitPricingProfile ^-- StorageResourcePricingProfile
interface PricingProfileITF { interface PricingProfileITF {
GetPrice(quantity float64, val float64, start date, end date, request) float64 GetPriceHT(quantity float64, val float64, start date, end date, request) float64
IsPurchased() bool IsPurchased() bool
} }
class AccessPricingProfile { class AccessPricingProfile {
@@ -319,7 +319,7 @@ Workflow "1 " --* "many " ExploitResourceSet
class Workflow {} class Workflow {}
interface PricedItemITF { interface PricedItemITF {
getPrice(request) float64, error GetPriceHT(request) float64, error
} }
@enduml @enduml

View File

@@ -62,6 +62,7 @@ func IsMySelf(peerID string) (bool, string) {
// Peer is a struct that represents a peer // Peer is a struct that represents a peer
type Peer struct { type Peer struct {
utils.AbstractObject utils.AbstractObject
PeerID string `json:"peer_id" bson:"peer_id" validate:"required"` PeerID string `json:"peer_id" bson:"peer_id" validate:"required"`
Url string `json:"url" bson:"url" validate:"required"` // Url is the URL of the peer (base64url) Url string `json:"url" bson:"url" validate:"required"` // Url is the URL of the peer (base64url)
WalletAddress string `json:"wallet_address" bson:"wallet_address" validate:"required"` // WalletAddress is the wallet address of the peer WalletAddress string `json:"wallet_address" bson:"wallet_address" validate:"required"` // WalletAddress is the wallet address of the peer

View File

@@ -68,7 +68,7 @@ func (wf *Graph) IsWorkflow(item GraphItem) bool {
} }
func (g *Graph) GetAverageTimeRelatedToProcessingActivity(start time.Time, processings []*resources.ProcessingResource, resource resources.ResourceInterface, func (g *Graph) GetAverageTimeRelatedToProcessingActivity(start time.Time, processings []*resources.ProcessingResource, resource resources.ResourceInterface,
f func(GraphItem) resources.ResourceInterface, instance int, bookingMode int, request *tools.APIRequest) (float64, float64, error) { f func(GraphItem) resources.ResourceInterface, instance int, partnership int, buying int, strategy int, bookingMode int, request *tools.APIRequest) (float64, float64, error) {
nearestStart := float64(10000000000) nearestStart := float64(10000000000)
oneIsInfinite := false oneIsInfinite := false
longestDuration := float64(0) longestDuration := float64(0)
@@ -80,7 +80,7 @@ func (g *Graph) GetAverageTimeRelatedToProcessingActivity(start time.Time, proce
} else if link.Source.ID == processing.GetID() && f(g.Items[link.Source.ID]) != nil && f(g.Items[link.Source.ID]).GetID() == resource.GetID() { // if the source is the processing and the destination is not a compute } else if link.Source.ID == processing.GetID() && f(g.Items[link.Source.ID]) != nil && f(g.Items[link.Source.ID]).GetID() == resource.GetID() { // if the source is the processing and the destination is not a compute
source = link.Destination.ID source = link.Destination.ID
} }
priced, err := processing.ConvertToPricedResource(tools.PROCESSING_RESOURCE, &instance, &bookingMode, request) priced, err := processing.ConvertToPricedResource(tools.PROCESSING_RESOURCE, &instance, &partnership, &buying, &strategy, &bookingMode, request)
if err != nil { if err != nil {
return 0, 0, err return 0, 0, err
} }
@@ -112,7 +112,8 @@ func (g *Graph) GetAverageTimeRelatedToProcessingActivity(start time.Time, proce
/* /*
* GetAverageTimeBeforeStart is a function that returns the average time before the start of a processing * GetAverageTimeBeforeStart is a function that returns the average time before the start of a processing
*/ */
func (g *Graph) GetAverageTimeProcessingBeforeStart(average float64, processingID string, instance int, bookingMode int, request *tools.APIRequest) (float64, error) { func (g *Graph) GetAverageTimeProcessingBeforeStart(average float64, processingID string,
instance int, partnership int, buying int, strategy int, bookingMode int, request *tools.APIRequest) (float64, error) {
currents := []float64{} // list of current time currents := []float64{} // list of current time
for _, link := range g.Links { // for each link for _, link := range g.Links { // for each link
var source string // source is the source of the link var source string // source is the source of the link
@@ -128,7 +129,7 @@ func (g *Graph) GetAverageTimeProcessingBeforeStart(average float64, processingI
if r == nil { // if item is nil, continue if r == nil { // if item is nil, continue
continue continue
} }
priced, err := r.ConvertToPricedResource(dt, &instance, &bookingMode, request) priced, err := r.ConvertToPricedResource(dt, &instance, &partnership, &buying, &strategy, &bookingMode, request)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@@ -136,7 +137,7 @@ func (g *Graph) GetAverageTimeProcessingBeforeStart(average float64, processingI
if current < 0 { // if current is negative, its means that duration of a before could be infinite continue if current < 0 { // if current is negative, its means that duration of a before could be infinite continue
return current, nil return current, nil
} }
add, err := g.GetAverageTimeProcessingBeforeStart(current, source, instance, bookingMode, request) add, err := g.GetAverageTimeProcessingBeforeStart(current, source, instance, partnership, buying, strategy, bookingMode, request)
if err != nil { if err != nil {
return 0, err return 0, err
} }