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: make segment condition value dynamic #3245

Merged
merged 4 commits into from
Jan 25, 2024

Conversation

matthewelwell
Copy link
Contributor

Changes

For self hosted customers, the limit on the length of each segment condition is very restrictive for little benefit. The restriction in our SaaS environment is primarily driven by the size limit that we have imposed on us by dynamodb (although hopefully this will be worked around in the not too distant future).

This PR allows self hosted customers to define the length of that column via an environment variable. I have added documentation warning against it's use for already running instances of Flagsmith.

How did you test this code?

Ran the following:

export DATABASE_URL=<url of an empty database>
export SEGMENT_CONDITION_VALUE_LIMIT=1999999
python manage.py migrate
python manage.py runserver

and validated the following:

  1. The database column was created with a max size limit of 1999999B
  2. It is possible to create a segment condition with a size exceeding the default limit of 1000B
  3. It is not possible to create a segment condition with a size exceeding the configured limit of 1999999B
  4. Using a segment with a value that has a size close to the limit still works in a reasonable manner

Note that I also ran this to confirm that django doesn't think there are migrations to run (assuming the environment variable is not modified):

❯ python manage.py makemigrations segments
System check identified some issues:

WARNINGS:
?: (axes.W002) You do not have 'axes.middleware.AxesMiddleware' in your settings.MIDDLEWARE.
No changes detected in app 'segments'

@matthewelwell matthewelwell requested review from a team and zachaysan and removed request for a team January 5, 2024 17:22
Copy link

vercel bot commented Jan 5, 2024

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

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2024 8:58am
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2024 8:58am
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2024 8:58am

@github-actions github-actions bot added api Issue related to the REST API docs Documentation updates labels Jan 5, 2024
Copy link
Contributor

github-actions bot commented Jan 5, 2024

Uffizzi Preview deployment-43896 was deleted.

@codecov-commenter
Copy link

codecov-commenter commented Jan 5, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (445dc2b) 95.96% compared to head (06537ef) 76.38%.
Report is 10 commits behind head on main.

❗ Current head 06537ef differs from pull request most recent head d933ec1. Consider uploading reports for the commit d933ec1 to get more accurate results

Files Patch % Lines
api/webhooks/webhooks.py 94.23% 3 Missing ⚠️
api/app/settings/common.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3245       +/-   ##
===========================================
- Coverage   95.96%   76.38%   -19.59%     
===========================================
  Files        1062     1033       -29     
  Lines       32297    31254     -1043     
===========================================
- Hits        30993    23872     -7121     
- Misses       1304     7382     +6078     

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

Copy link
Contributor

@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.

One small question / suggestion but overall the approach makes sense.

@matthewelwell matthewelwell added this pull request to the merge queue Jan 25, 2024
Merged via the queue into main with commit dea63df Jan 25, 2024
@matthewelwell matthewelwell deleted the feat/make-segment-condition-value-dynamic branch January 25, 2024 11:57
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 docs Documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants