Compare commits
	
		
			2 Commits
		
	
	
		
			34f01e9740
			...
			6ab774cc43
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					6ab774cc43 | ||
| 
						 | 
					2748b59221 | 
@@ -6,7 +6,6 @@ import (
 | 
				
			|||||||
	"cloud.o-forge.io/core/oc-lib/dbs"
 | 
						"cloud.o-forge.io/core/oc-lib/dbs"
 | 
				
			||||||
	"cloud.o-forge.io/core/oc-lib/models/common/enum"
 | 
						"cloud.o-forge.io/core/oc-lib/models/common/enum"
 | 
				
			||||||
	"cloud.o-forge.io/core/oc-lib/models/common/models"
 | 
						"cloud.o-forge.io/core/oc-lib/models/common/models"
 | 
				
			||||||
	"cloud.o-forge.io/core/oc-lib/models/common/pricing"
 | 
					 | 
				
			||||||
	"cloud.o-forge.io/core/oc-lib/models/utils"
 | 
						"cloud.o-forge.io/core/oc-lib/models/utils"
 | 
				
			||||||
	"cloud.o-forge.io/core/oc-lib/tools"
 | 
						"cloud.o-forge.io/core/oc-lib/tools"
 | 
				
			||||||
	"go.mongodb.org/mongo-driver/bson/primitive"
 | 
						"go.mongodb.org/mongo-driver/bson/primitive"
 | 
				
			||||||
@@ -16,8 +15,8 @@ import (
 | 
				
			|||||||
* Booking is a struct that represents a booking
 | 
					* Booking is a struct that represents a booking
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
type Booking struct {
 | 
					type Booking struct {
 | 
				
			||||||
	utils.AbstractObject                       // AbstractObject contains the basic fields of an object (id, name)
 | 
						utils.AbstractObject                        // AbstractObject contains the basic fields of an object (id, name)
 | 
				
			||||||
	PricedItem           pricing.PricedItemITF `json:"priced_item,omitempty" bson:"priced_item,omitempty"` // We need to add the validate:"required" tag once the pricing feature is implemented, removed to avoid handling the error
 | 
						PricedItem           map[string]interface{} `json:"priced_item,omitempty" bson:"priced_item,omitempty"` // We need to add the validate:"required" tag once the pricing feature is implemented, removed to avoid handling the error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ResumeMetrics    map[string]map[string]models.MetricResume `json:"resume_metrics,omitempty" bson:"resume_metrics,omitempty"`
 | 
						ResumeMetrics    map[string]map[string]models.MetricResume `json:"resume_metrics,omitempty" bson:"resume_metrics,omitempty"`
 | 
				
			||||||
	ExecutionMetrics map[string][]models.MetricsSnapshot       `json:"metrics,omitempty" bson:"metrics,omitempty"`
 | 
						ExecutionMetrics map[string][]models.MetricsSnapshot       `json:"metrics,omitempty" bson:"metrics,omitempty"`
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package workflow_execution
 | 
					package workflow_execution
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -141,13 +142,16 @@ func (d *WorkflowExecution) buyEach(bs pricing.BillingStrategy, executionsID str
 | 
				
			|||||||
		if s := priced.GetLocationStart(); s != nil {
 | 
							if s := priced.GetLocationStart(); s != nil {
 | 
				
			||||||
			start = *s
 | 
								start = *s
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							var m map[string]interface{}
 | 
				
			||||||
 | 
							b, _ := json.Marshal(priced)
 | 
				
			||||||
 | 
							json.Unmarshal(b, &m)
 | 
				
			||||||
		end := start.Add(time.Duration(priced.GetExplicitDurationInS()) * time.Second)
 | 
							end := start.Add(time.Duration(priced.GetExplicitDurationInS()) * time.Second)
 | 
				
			||||||
		bookingItem := &purchase_resource.PurchaseResource{
 | 
							bookingItem := &purchase_resource.PurchaseResource{
 | 
				
			||||||
			AbstractObject: utils.AbstractObject{
 | 
								AbstractObject: utils.AbstractObject{
 | 
				
			||||||
				UUID: uuid.New().String(),
 | 
									UUID: uuid.New().String(),
 | 
				
			||||||
				Name: d.GetName() + "_" + executionsID + "_" + wfID,
 | 
									Name: d.GetName() + "_" + executionsID + "_" + wfID,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			PricedItem:   priced,
 | 
								PricedItem:   m,
 | 
				
			||||||
			ExecutionsID: executionsID,
 | 
								ExecutionsID: executionsID,
 | 
				
			||||||
			DestPeerID:   priced.GetCreatorID(),
 | 
								DestPeerID:   priced.GetCreatorID(),
 | 
				
			||||||
			ResourceID:   priced.GetID(),
 | 
								ResourceID:   priced.GetID(),
 | 
				
			||||||
@@ -189,12 +193,15 @@ func (d *WorkflowExecution) bookEach(executionsID string, wfID string, dt tools.
 | 
				
			|||||||
			start = *s
 | 
								start = *s
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		end := start.Add(time.Duration(priced.GetExplicitDurationInS()) * time.Second)
 | 
							end := start.Add(time.Duration(priced.GetExplicitDurationInS()) * time.Second)
 | 
				
			||||||
 | 
							var m map[string]interface{}
 | 
				
			||||||
 | 
							b, _ := json.Marshal(priced)
 | 
				
			||||||
 | 
							json.Unmarshal(b, &m)
 | 
				
			||||||
		bookingItem := &booking.Booking{
 | 
							bookingItem := &booking.Booking{
 | 
				
			||||||
			AbstractObject: utils.AbstractObject{
 | 
								AbstractObject: utils.AbstractObject{
 | 
				
			||||||
				UUID: uuid.New().String(),
 | 
									UUID: uuid.New().String(),
 | 
				
			||||||
				Name: d.GetName() + "_" + executionsID + "_" + wfID,
 | 
									Name: d.GetName() + "_" + executionsID + "_" + wfID,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			PricedItem:        priced,
 | 
								PricedItem:        m,
 | 
				
			||||||
			ExecutionsID:      executionsID,
 | 
								ExecutionsID:      executionsID,
 | 
				
			||||||
			State:             enum.SCHEDULED,
 | 
								State:             enum.SCHEDULED,
 | 
				
			||||||
			ResourceID:        priced.GetID(),
 | 
								ResourceID:        priced.GetID(),
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user