[Rule Management] Move calculation of rule source outside of applyRuleUpdate #199720
+21
−14
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.
Summary
This is a small performance improvement that came out of this discussion on a previous PR. Note that the code in question is behind a feature flag (
prebuiltRulesCustomizationEnabled
). This issue relates to the Prebuilt Rule Import work, and its associated benchmarking effort.Context
With the current implementation, there are instances where we call
applyRuleUpdate
but do not want/need it to calculate rule source (e.g. when called fromimportRules
, which pre-calculates the rule_source for incoming rules before passing them toimportRule
.Instead of adding a flag to conditionally call
calculateRuleSource
from withinapplyRuleUpdate
I've opted to separate the two functions as these seem to be logically distinct actions.The three existing calls to
applyRuleUpdate
have been updated to be functionally equivalent.Effect
The effect of this PR is that we will no longer unnecessarily call
fetchAssetsByVersion
for each individual rule being imported, which should improve performance of rule import.For maintainers