Skip to content
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

feat: Add version_of and matches to rules and conditions #4988

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

zachaysan
Copy link
Contributor

Changes

When creating a new change request for segments we need a way of tracing which provided rules and conditions match the candidate change request so that the frontend can more visually associate which rules and conditions match between the change request and the targeted segment (the one that will be updated).

To do so I've reused the concept of version_of which was originally used for segments and I associate a rule to another rule (or sub-rule to sub-rule) and in that process also match up conditions at the same layer. If at least one condition matches, then the sub-rule and rule match and future matching for the subsequent sub-rule is guided by holding onto the match between the parent rule and its sister rule. This way matches are only ever tree like in nature.

Remaining work

Since the matching code is ready in this PR another PR will need to be opened to tie in these changes into the relevant code. Probably both the Workflows and Commons will need to be updated.

How did you test this code?

Lots of new tests. Some are simple, like checking that version_of gets correctly set, which is necessary due to an audit log bug we had when version_of was setup for the segments work.

@zachaysan zachaysan requested a review from a team as a code owner January 10, 2025 14:57
@zachaysan zachaysan requested review from matthewelwell and removed request for a team January 10, 2025 14:57
Copy link

vercel bot commented Jan 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 31, 2025 2:37pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 31, 2025 2:37pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Jan 31, 2025 2:37pm

@github-actions github-actions bot added api Issue related to the REST API feature New feature or request labels Jan 10, 2025
Copy link
Contributor

github-actions bot commented Jan 10, 2025

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-4988 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-4988 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-4988 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-4988 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-4988 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-4988 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-4988 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-4988 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-4988 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-4988 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-4988 Finished ✅ Results

Copy link
Contributor

github-actions bot commented Jan 10, 2025

Uffizzi Ephemeral Environment deployment-59778

☁️ https://app.uffizzi.com/github.com/Flagsmith/flagsmith/pull/4988

📄 View Application Logs etc.

What is Uffizzi? Learn more!

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.45%. Comparing base (b0d0a80) to head (41ec3ad).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4988      +/-   ##
==========================================
+ Coverage   97.43%   97.45%   +0.01%     
==========================================
  Files        1214     1216       +2     
  Lines       42253    42544     +291     
==========================================
+ Hits        41169    41460     +291     
  Misses       1084     1084              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Jan 10, 2025
@@ -170,7 +170,7 @@ hubspot-api-client = "^8.2.1"
djangorestframework-dataclasses = "^1.3.1"
pyotp = "^2.9.0"
flagsmith-task-processor = { git = "https://github.com/Flagsmith/flagsmith-task-processor", tag = "v1.1.1" }
flagsmith-common = { git = "https://github.com/Flagsmith/flagsmith-common", tag = "v1.4.2" }
flagsmith-common = { git = "https://github.com/Flagsmith/flagsmith-common", branch = "feat/add_version_of_to_rules_and_conditions" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remember to update these once we've got builds in those packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

api/segments/models.py Outdated Show resolved Hide resolved
api/segments/models.py Outdated Show resolved Hide resolved
api/segments/models.py Outdated Show resolved Hide resolved
api/segments/models.py Outdated Show resolved Hide resolved
api/segments/models.py Outdated Show resolved Hide resolved
api/segments/models.py Outdated Show resolved Hide resolved
api/segments/models.py Outdated Show resolved Hide resolved
api/segments/models.py Outdated Show resolved Hide resolved
api/segments/models.py Outdated Show resolved Hide resolved
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Jan 29, 2025
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Jan 29, 2025
@matthewelwell matthewelwell force-pushed the feat/add_version_of_to_rules_and_conditions branch from af6df13 to 6e5894e Compare January 29, 2025 12:03
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Jan 29, 2025
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Jan 29, 2025
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Jan 31, 2025
Copy link
Contributor Author

@zachaysan zachaysan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I'm on my last day I'd like to add some comments to this PR about where we are at.

Overall this work should be considered to be feature complete. Change requests for segments can be created, updated, approved, and committed in order to update the underlying segment. The attribute version_of was added to rules and conditions to allow for the frontend to assign diffs in conjunction with what a likely diff should be.

In order to properly merge this code the following updates need to happen:

  1. flagsmith-common in pyproject.toml must be updated to a new tag that include previously merged work, which includes feat: Add version_of to rules and conditions serializers flagsmith-common#11.
  2. This PR https://github.com/Flagsmith/flagsmith-workflows/pull/63 needs updating as well, both for the same flagsmith-common library as well as for the image in the docker-compose file which must be set to ghcr.io/flagsmith/flagsmith-api-test:main. I'm not sure how to solve the circular dependency because we also must...
  3. Update the workflows-logic in pyproject.toml in this repo once step 2 can be merged into the workflows repository and tagged as a release.

When in doubt about how to run some chunk of functionality, look into the tests in the workflows PR here: https://github.com/Flagsmith/flagsmith-workflows/pull/63 including tests that pre-exist that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants