light modification
This commit is contained in:
		@@ -121,8 +121,9 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
 | 
			
		||||
	ps, priceds, err := plan[*resources.ProcessingResource](tools.PROCESSING_RESOURCE, wf, priceds, request, wf.Graph.IsProcessing,
 | 
			
		||||
		func(res resources.ResourceInterface, priced pricing.PricedItemITF) (time.Time, float64) {
 | 
			
		||||
			return start.Add(time.Duration(wf.Graph.GetAverageTimeProcessingBeforeStart(0, res.GetID(), request)) * time.Second), priced.GetExplicitDurationInS()
 | 
			
		||||
		}, func(started time.Time, duration float64) time.Time {
 | 
			
		||||
			return started.Add(time.Duration(duration))
 | 
			
		||||
		}, func(started time.Time, duration float64) *time.Time {
 | 
			
		||||
			s := started.Add(time.Duration(duration))
 | 
			
		||||
			return &s
 | 
			
		||||
		})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, priceds, nil, err
 | 
			
		||||
@@ -130,8 +131,8 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
 | 
			
		||||
	if _, priceds, err = plan[resources.ResourceInterface](tools.DATA_RESOURCE, wf, priceds, request, wf.Graph.IsData,
 | 
			
		||||
		func(res resources.ResourceInterface, priced pricing.PricedItemITF) (time.Time, float64) {
 | 
			
		||||
			return start, 0
 | 
			
		||||
		}, func(started time.Time, duration float64) time.Time {
 | 
			
		||||
			return *end
 | 
			
		||||
		}, func(started time.Time, duration float64) *time.Time {
 | 
			
		||||
			return end
 | 
			
		||||
		}); err != nil {
 | 
			
		||||
		return 0, priceds, nil, err
 | 
			
		||||
	}
 | 
			
		||||
@@ -145,8 +146,9 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
 | 
			
		||||
					return r
 | 
			
		||||
				}, request)
 | 
			
		||||
				return start.Add(time.Duration(nearestStart) * time.Second), longestDuration
 | 
			
		||||
			}, func(started time.Time, duration float64) time.Time {
 | 
			
		||||
				return started.Add(time.Duration(duration))
 | 
			
		||||
			}, func(started time.Time, duration float64) *time.Time {
 | 
			
		||||
				s := started.Add(time.Duration(duration))
 | 
			
		||||
				return &s
 | 
			
		||||
			}); err != nil {
 | 
			
		||||
			return 0, priceds, nil, err
 | 
			
		||||
		}
 | 
			
		||||
@@ -166,8 +168,9 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
 | 
			
		||||
				longest = neoLongest
 | 
			
		||||
			}
 | 
			
		||||
			return start.Add(time.Duration(common.GetPlannerNearestStart(start, priceds, request)) * time.Second), longest
 | 
			
		||||
		}, func(start time.Time, longest float64) time.Time {
 | 
			
		||||
			return start.Add(time.Duration(longest) * time.Second)
 | 
			
		||||
		}, func(start time.Time, longest float64) *time.Time {
 | 
			
		||||
			s := start.Add(time.Duration(longest) * time.Second)
 | 
			
		||||
			return &s
 | 
			
		||||
		}); err != nil {
 | 
			
		||||
		return 0, priceds, nil, err
 | 
			
		||||
	}
 | 
			
		||||
@@ -175,7 +178,7 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func plan[T resources.ResourceInterface](dt tools.DataType, wf *Workflow, priceds map[tools.DataType][]pricing.PricedItemITF, request *tools.APIRequest,
 | 
			
		||||
	f func(graph.GraphItem) bool, start func(resources.ResourceInterface, pricing.PricedItemITF) (time.Time, float64), end func(time.Time, float64) time.Time) ([]T, map[tools.DataType][]pricing.PricedItemITF, error) {
 | 
			
		||||
	f func(graph.GraphItem) bool, start func(resources.ResourceInterface, pricing.PricedItemITF) (time.Time, float64), end func(time.Time, float64) *time.Time) ([]T, map[tools.DataType][]pricing.PricedItemITF, error) {
 | 
			
		||||
	resources := []T{}
 | 
			
		||||
	for _, item := range wf.GetGraphItems(f) {
 | 
			
		||||
		if priceds[dt] == nil {
 | 
			
		||||
@@ -189,9 +192,13 @@ func plan[T resources.ResourceInterface](dt tools.DataType, wf *Workflow, priced
 | 
			
		||||
		started, duration := start(realItem, priced)
 | 
			
		||||
		priced.SetLocationStart(started)
 | 
			
		||||
		if duration >= 0 {
 | 
			
		||||
			priced.SetLocationEnd(end(started, duration))
 | 
			
		||||
			if e := end(started, duration); e != nil {
 | 
			
		||||
				priced.SetLocationEnd(*e)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if e := end(started, priced.GetExplicitDurationInS()); end != nil {
 | 
			
		||||
			priced.SetLocationEnd(*e)
 | 
			
		||||
		}
 | 
			
		||||
		priced.SetLocationEnd(end(started, priced.GetExplicitDurationInS()))
 | 
			
		||||
		resources = append(resources, realItem.(T))
 | 
			
		||||
		priceds[dt] = append(priceds[dt], priced)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user