Conversation
Contributor
Author
|
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @Mallika05 and the rest of your teammates on |
Contributor
|
The additions look good but I have an ask for changes to each function, it's slightly better to do this: compare := insp.conf.Value
if insp.conf.Object.SourceKey == "" {
f, err := strconv.ParseFloat(string(msg.Data()), 64)
if err != nil {
return false, err
}
return insp.match(f, compare), nil
}
target := msg.GetValue(insp.conf.Object.TargetKey)
if target.Exists() {
compare = target.Float()
}
v := msg.GetValue(insp.conf.Object.SourceKey)
return insp.match(v.Float(), compare), nilInstead of this: compare := insp.conf.Value
target := msg.GetValue(insp.conf.Object.TargetKey)
if target.Exists() {
compare = target.Float()
}
if insp.conf.Object.SourceKey == "" {
f, err := strconv.ParseFloat(string(msg.Data()), 64)
if err != nil {
return false, err
}
return insp.match(f, compare), nil
}
v := msg.GetValue(insp.conf.Object.SourceKey)
return insp.match(v.Float(), compare), nilIf If someone were to configure these functions like that, then that would be a user error (identical to this one). |
jshlbrd
approved these changes
Jul 26, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Updated the following conditions to support comparisons between
source_keyandtarget_keyvalues.Example:
sub.condition.number.less_than( settings={object: {source_key: 'a', target_key: 'z'}} )sub.condition.string.less_than( settings={object: {source_key: 'a', target_key: 'z'}} )Motivation and Context
This adds flexibility to accept both static values or
target_keywhichever is provided in the config. Static value is ignored iftarget_keyis present in the condition. This solves the issue discussed here: #64.How Has This Been Tested?
Added unit tests in respective files.
Types of changes
Checklist: