Flagsmith / Flagsmith/flagsmith
Cohort segments lack `rules_data`
- Dominant language
- Python
- Stars
- 6.6k
- Forks
- 567
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 121
Description
The `Segment.rules_data` field was introduced recently (https://github.com/Flagsmith/flagsmith/issues/7815) as part of a larger effort (https://github.com/Flagsmith/flagsmith/issues/7814) to stop reading from row-based rules and conditions, and instead use a pure JSON field.
However, segments added by the cohorts app only add row-based rules and conditions.
## Acceptance criteria
- [ ] Segments managed in the `cohorts` app earn `rules_data`
- [ ] Any historical segment created by this app so far also earns `rules_data`
## No-goals
- Please **DO NOT** introduce a service to own writing segments because of this. While a service may sound like an obvious choice towards normalisation, it will immediately become unjustified once we no longer have row-based rules and conditions (https://github.com/Flagsmith/flagsmith/issues/7818), and `rules_data` — then renamed to just `rules` — is but a regular field like the others.
Contributor guide
Research direction
Start in the cohorts app by tracing where segments are created and compare that path with the Segment.rules_data field. Check how historical cohort segments can be updated, then use the relevant cohorts tests or database checks to confirm both newly created and existing segments have rules_data without introducing a service.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100