-
Notifications
You must be signed in to change notification settings - Fork 14
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
feature flag lists backend changes #1719
Conversation
This change is good by me but I'd like @VivekFitkariwala and others to give it a good look. I'm going to proceed with the assumption that this is pretty much how it will be for re-creating the include/exclude modal stories. |
Ok, I'm working on the modals for adding/modifying a flag...we have slightly different constraints for add and modify requests that we can enforce with types, so would you say these are accurate representations of our types (FeatureFlag being the full document from the db that we should expect as a response?)
|
This looks correct, with the following exceptions:
|
@bcb37 I am not sure why you have deleted the junction table of |
@VivekFitkariwala I was thinking it's better to simplify the database and data models. We can now store the information we need with fewer moving parts, and query with fewer joins. And now we can manage the inclusions and exclusions from the front end just using the segment endpoints that already exist. Is there a compelling reason to use those junction tables for the relationships between feature flags and segments? |
@bcb37 this change is adding property which doesn't belong to Segment and that is the concern. I don't know if we are facing any issues because of this specific join. |
@VivekFitkariwala Ok, that makes sense to restore the junction tables. I think we'll still need new endpoints for editing the lists. They should be relatively similar to the /segment endpoints, with the addition of managing the junction table entries. Since we don't create feature flags initially with any exclusion or inclusion lists, I still think it makes sense to edit them separately. |
@VivekFitkariwala please consider this the highest priority review... putting comments from dev sync in writing: it was suggested that also enums for the Zack mentioned that it might be best API practice to only need to send changed fields when updating a known entity, but that is a larger architectural design change, currently we tend to always pass the entire document (as was my understanding of that concern) |
…gieLearningWeb/UpGrade into feature/feature-flag-lists-backend
*/ | ||
@Delete('/inclusionList/:id') | ||
public async deleteInclusionList( | ||
@Param('id') segmentId: string, |
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.
You can modify this and use @Params . This way you can create a class validator to validate id and remove the if condition from the line below.
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.
This seems to be how single UUID parameters are verified throughout the codebase. If we create a validator that checks whether something's a UUID, we should probably start using it everywhere. Maybe a separate task for that.
*/ | ||
@Delete('/exclusionList/:id') | ||
public async deleteExclusionList( | ||
@Param('id') segmentId: string, |
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.
Same as above
@Delete('/exclusionList/:id') | ||
public async deleteExclusionList( | ||
@Param('id') segmentId: string, | ||
@CurrentUser() currentUser: User, |
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.
currentUser can be removed
*/ | ||
@Put('/exclusionList/:id') | ||
public async updateExclusionList( | ||
@Param('id') segmentId: string, |
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.
Same as below
@@ -53,6 +53,12 @@ export interface getSegmentData { | |||
* type: array | |||
* items: | |||
* type: string | |||
* enabled: |
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.
Do we need this?
onDelete: 'CASCADE', | ||
primary: true, | ||
}) | ||
@JoinColumn() | ||
public featureFlag: FeatureFlag; | ||
|
||
@Column() |
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.
We can add a default value as false.
onDelete: 'CASCADE', | ||
primary: true, | ||
}) | ||
@JoinColumn() | ||
public featureFlag: FeatureFlag; | ||
|
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.
Same as in Segment Exclusion
if (featureFlag) { | ||
const deletedFlag = await this.featureFlagRepository.deleteById(featureFlagId, transactionalEntityManager); | ||
|
||
featureFlag.featureFlagSegmentInclusion.forEach(async (segmentInclusion) => { |
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.
Do we need this? The cascade delete should automatically delete this.
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.
In that case the transaction is not required
@danoswaltCL Sorry for the delay. I have added my review comments. |
With these changes, the feature flag endpoints will not be used to perform CRUD operations on the inclusion and exclusion lists (with the exception of GET by :id, which will return the lists along with the other feature flag data)
Operations on the lists will be performed using the segments endpoints, which have three new optional attributes:
Example body for flag creation (POST to /api/flags endpoint):
Example body to add or edit an inclusion list for the above (POST to /api/flags/addInclusionList endpoint):
Deleting lists can be done by hitting the
/api/segments/:id
DELETE endpointThis would use the ID of the feature flag; it's for a 'segments' list, which can only have one element.
assuming the above UUIDs refer to entities that exist in the db.