-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(versioning): multiple versioned segment overrides added to environment document #3974
fix(versioning): multiple versioned segment overrides added to environment document #3974
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Uffizzi Preview |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3974 +/- ##
=======================================
Coverage 96.18% 96.18%
=======================================
Files 1141 1141
Lines 36507 36526 +19
=======================================
+ Hits 35114 35133 +19
Misses 1393 1393 ☔ View full report in Codecov by Sentry. |
api/util/mappers/engine.py
Outdated
Iterable["EnvironmentFeatureVersion"] | None | ||
) = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: optional argument is not needed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
api/util/mappers/engine.py
Outdated
) -> Dict[int, List["FeatureState"]]: | ||
feature_states_by_segment_id = {} | ||
latest_environment_feature_versions = latest_environment_feature_versions or [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert to set for faster membership checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we had to do an iteration to convert to a set, I ended up using a set of uuids instead of the object itself. This should give us an extra (very minor) boost in performance too I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, requested a minor cleanup
…tatus in private function
api/util/mappers/engine.py
Outdated
@@ -419,14 +430,26 @@ def _get_prioritised_feature_states( | |||
def _get_segment_feature_states( | |||
segments: Iterable["Segment"], | |||
environment_id: int, | |||
latest_environment_feature_version_uuids: Iterable["EnvironmentFeatureVersion"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The typing is incorrect here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gah, good spot! Fixing...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Thanks for submitting a PR! Please check the boxes below:
pre-commit
to check lintingdocs/
if required so people know about the feature!Changes
This PR fixes an issue found in testing where we were previously adding all versions of a given segment override to the environment document. It achieves this by (unfortunately) adding an extra query to the mapping function to grab the latest versions for an environment and then filtering out any segment overrides that don't have a matching version.
How did you test this code?
Added an explicit unit test on the mapper function to test it.