Expressions: Use enumerations rather than strings (#83741)
This commit is contained in:
@@ -205,14 +205,14 @@ func (gr *ReduceCommand) Execute(ctx context.Context, _ time.Time, vars mathexp.
|
||||
type ResampleCommand struct {
|
||||
Window time.Duration
|
||||
VarToResample string
|
||||
Downsampler string
|
||||
Upsampler string
|
||||
Downsampler mathexp.ReducerID
|
||||
Upsampler mathexp.Upsampler
|
||||
TimeRange TimeRange
|
||||
refID string
|
||||
}
|
||||
|
||||
// NewResampleCommand creates a new ResampleCMD.
|
||||
func NewResampleCommand(refID, rawWindow, varToResample string, downsampler string, upsampler string, tr TimeRange) (*ResampleCommand, error) {
|
||||
func NewResampleCommand(refID, rawWindow, varToResample string, downsampler mathexp.ReducerID, upsampler mathexp.Upsampler, tr TimeRange) (*ResampleCommand, error) {
|
||||
// TODO: validate reducer here, before execution
|
||||
window, err := gtime.ParseDuration(rawWindow)
|
||||
if err != nil {
|
||||
@@ -271,7 +271,11 @@ func UnmarshalResampleCommand(rn *rawNode) (*ResampleCommand, error) {
|
||||
return nil, fmt.Errorf("expected resample downsampler to be a string, got type %T", upsampler)
|
||||
}
|
||||
|
||||
return NewResampleCommand(rn.RefID, window, varToResample, downsampler, upsampler, rn.TimeRange)
|
||||
return NewResampleCommand(rn.RefID, window,
|
||||
varToResample,
|
||||
mathexp.ReducerID(downsampler),
|
||||
mathexp.Upsampler(upsampler),
|
||||
rn.TimeRange)
|
||||
}
|
||||
|
||||
// NeedsVars returns the variable names (refIds) that are dependencies
|
||||
|
||||
Reference in New Issue
Block a user