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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0b6c551
Version rules and conditions
zachaysan Jan 10, 2025
1e874e8
Create tests for versioned rules and conditions as well as matches
zachaysan Jan 10, 2025
6eb58a0
Add version_of fields and add matches for segments rules and conditions
zachaysan Jan 10, 2025
80fd54e
Merge branch 'main' into feat/add_version_of_to_rules_and_conditions
zachaysan Jan 10, 2025
3c5ffea
Update lock file and pyproject.toml
zachaysan Jan 10, 2025
10ba9d1
Alter test to cover case where rule is already parted of the matched …
zachaysan Jan 16, 2025
11e387c
Add docstrings, change variables to `self_` and remove pragma: no cover
zachaysan Jan 16, 2025
760fd6a
Fix conflicts and merge branch 'main' into feat/add_version_of_to_rul…
zachaysan Jan 16, 2025
d349a62
Update method name and associated tests
zachaysan Jan 20, 2025
3c204af
Update method names and add more info to docstrings
zachaysan Jan 20, 2025
3dcede8
Fix conflicts and merge branch 'main' into feat/add_version_of_to_rul…
zachaysan Jan 20, 2025
6351031
Update docstrings, add comments, and refactor condition matching logic
zachaysan Jan 23, 2025
d97e9b3
Add comments, update conditions for test, and create new condition ex…
zachaysan Jan 23, 2025
4ee905f
Fix conflicts and merge branch 'main' into feat/add_version_of_to_rul…
zachaysan Jan 23, 2025
e21c783
Create test for case where no conditions match
zachaysan Jan 24, 2025
19039b2
Update docstrings and variable names
zachaysan Jan 24, 2025
f578619
Update method names
zachaysan Jan 24, 2025
17defee
Update comments and docstring
zachaysan Jan 24, 2025
e2a63be
Update comments
zachaysan Jan 27, 2025
79a7720
Update poetry.lock with latest common
zachaysan Jan 27, 2025
692fc5f
Fix flaky migration
zachaysan Jan 28, 2025
aac17a3
Add create project level change requests
zachaysan Jan 28, 2025
fb4b633
Fix conflicts and merge branch 'main' into feat/add_version_of_to_rul…
zachaysan Jan 28, 2025
e460601
Fix migrations post merge
matthewelwell Jan 29, 2025
6e5894e
Merge branch 'refs/heads/main' into feat/add_version_of_to_rules_and_…
matthewelwell Jan 29, 2025
fc8b581
feat(segment-crs): code reabability improvements to #4988 (#5054)
matthewelwell Jan 29, 2025
9ba8ca3
Check for target conditions due to the exact matching case
zachaysan Jan 31, 2025
41ec3ad
Merge branch 'main' into feat/add_version_of_to_rules_and_conditions
zachaysan Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def insert_default_project_permissions(apps, schema_model):

PermissionModel.objects.get_or_create(
key=MANAGE_PROJECT_LEVEL_CHANGE_REQUESTS,
description=manage_description,
type=PROJECT_PERMISSION_TYPE,
defaults={"description": manage_description},
)
PermissionModel.objects.get_or_create(
key=APPROVE_PROJECT_LEVEL_CHANGE_REQUESTS,
description=approve_description,
type=PROJECT_PERMISSION_TYPE,
defaults={"description": approve_description},
)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from common.projects.permissions import CREATE_PROJECT_LEVEL_CHANGE_REQUESTS
from django.db import migrations

from permissions.models import PROJECT_PERMISSION_TYPE


def remove_default_project_permissions(apps, schema_model): # pragma: no cover
PermissionModel = apps.get_model("permissions", "PermissionModel")
PermissionModel.objects.get(key=CREATE_PROJECT_LEVEL_CHANGE_REQUESTS).delete()


def insert_default_project_permissions(apps, schema_model):
PermissionModel = apps.get_model("permissions", "PermissionModel")

create_description = "Ability to create project level change requests."

PermissionModel.objects.get_or_create(
key=CREATE_PROJECT_LEVEL_CHANGE_REQUESTS,
type=PROJECT_PERMISSION_TYPE,
defaults={"description": create_description},
)


class Migration(migrations.Migration):

dependencies = [("projects", "0026_add_change_request_approval_limit_to_projects")]

operations = [
migrations.RunPython(
insert_default_project_permissions,
reverse_code=remove_default_project_permissions,
),
]
4 changes: 2 additions & 2 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,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.2.0" }
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.

tzdata = "^2024.1"
djangorestframework-simplejwt = "^5.3.1"
structlog = "^24.4.0"
Expand All @@ -198,7 +198,7 @@ flagsmith-ldap = { git = "https://github.com/flagsmith/flagsmith-ldap", tag = "v
optional = true

[tool.poetry.group.workflows.dependencies]
workflows-logic = { git = "https://github.com/flagsmith/flagsmith-workflows", tag = "v2.7.6" }
workflows-logic = { git = "https://github.com/flagsmith/flagsmith-workflows", branch = "feat/add_matches_to_workflows" }
matthewelwell marked this conversation as resolved.
Show resolved Hide resolved

[tool.poetry.group.licensing]
optional = true
Expand Down
60 changes: 60 additions & 0 deletions api/segments/migrations/0028_version_rules_and_conditions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Generated by Django 4.2.17 on 2025-01-08 15:21

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("segments", "0027_historicalsegmentrule"),
]

operations = [
migrations.AddField(
model_name="condition",
name="version_of",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="versioned_conditions",
to="segments.condition",
),
),
migrations.AddField(
model_name="historicalcondition",
name="version_of",
field=models.ForeignKey(
blank=True,
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="segments.condition",
),
),
migrations.AddField(
model_name="segmentrule",
name="version_of",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="versioned_rules",
to="segments.segmentrule",
),
),
migrations.AddField(
model_name="historicalsegmentrule",
name="version_of",
field=models.ForeignKey(
blank=True,
db_constraint=False,
null=True,
on_delete=django.db.models.deletion.DO_NOTHING,
related_name="+",
to="segments.segmentrule",
),
),
]
Loading
Loading