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: Clone identity flag states #3773

Merged
merged 17 commits into from
Apr 24, 2024
Merged

Conversation

novakzaballa
Copy link
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

Add Core and Edge edpoints for clonning identity's flag states.

How did you test this code?

Integrations tests added

Copy link

vercel bot commented Apr 16, 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 Apr 24, 2024 3:15pm
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2024 3:15pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2024 3:15pm

Copy link
Contributor

github-actions bot commented Apr 16, 2024

Uffizzi Preview deployment-50772 was deleted.

@codecov-commenter
Copy link

codecov-commenter commented Apr 16, 2024

Codecov Report

Attention: Patch coverage is 99.41176% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 95.93%. Comparing base (cd1f79c) to head (938ade1).
Report is 87 commits behind head on main.

Files Patch % Lines
api/features/views.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3773      +/-   ##
==========================================
+ Coverage   95.89%   95.93%   +0.04%     
==========================================
  Files        1102     1122      +20     
  Lines       34707    35656     +949     
==========================================
+ Hits        33282    34208     +926     
- Misses       1425     1448      +23     

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

@novakzaballa
Copy link
Contributor Author

I am tempted to create one or a couple of fixtures that return all the assets used in the integration tests since they both, API Core and the EDdge API tests, are very similar, even the asserts are almost the same.

@novakzaballa novakzaballa requested review from a team, zachaysan and matthewelwell April 16, 2024 06:17
@matthewelwell
Copy link
Contributor

@novakzaballa @zachaysan can you make sure all outstanding conversations on this PR are responded to or resolved please?

master_api_key=getattr(request, "master_api_key", None),
)

# Prepare response
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't we just do return self.all(request, *args, **kwargs) ? Also, bear in mind that the documentation for this endpoint needs updating as well!

target_identity=target_identity, source_identity=source_identity
)

# Prepare response
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, can we use return self.all(request, *args, **kwargs) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. Done. Also updated the autogenerate swagger command

Comment on lines 166 to 168
for feature_state in identity_flags:
overridden_feature_states[feature_state.feature.id] = feature_state
return overridden_feature_states
Copy link
Contributor

Choose a reason for hiding this comment

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

No, my point is that we should use feature_id instead of feature.id this will provide a small performance optimisation. I'll add a suggestion to the actual line in another comment to make it clear.

:return: dict[int, FeatureState] - Key: feature ID. Value: Overridden feature_state.
"""

return {fs.feature.id: fs for fs in self.identity_features.all()}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return {fs.feature.id: fs for fs in self.identity_features.all()}
return {fs.feature_id: fs for fs in self.identity_features.all()}

Related thread: #3773 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, we don't need to load the whole related feature but just the FK which is already in the feature_sate data.
Done

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.

I responded to your comments but they're just a suggestion at this point. Overall this looks good.

@novakzaballa novakzaballa added this pull request to the merge queue Apr 24, 2024
Merged via the queue into main with commit 01794b9 Apr 24, 2024
22 checks passed
@novakzaballa novakzaballa deleted the chore/clone-identity-flag-states branch April 24, 2024 15:41
@novakzaballa novakzaballa linked an issue Apr 30, 2024 that may be closed by this pull request
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compare / Clone Identities
4 participants