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

fix: Delete feature external resources when GitHub integration was deleted #3836

Conversation

novakzaballa
Copy link
Contributor

@novakzaballa novakzaballa commented Apr 24, 2024

…deleted

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

  • Delete feature external resources when GitHub integration was deleted

How did you test this code?

  • Unit test

Copy link

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

@github-actions github-actions bot added the api Issue related to the REST API label Apr 24, 2024
@novakzaballa novakzaballa changed the title chore: Delete feature external resources when github integration was deleted chore: Delete feature external resources when GitHub integration was deleted Apr 24, 2024
Copy link
Contributor

github-actions bot commented Apr 24, 2024

Uffizzi Preview deployment-50769 was deleted.

@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.96%. Comparing base (25afe3b) to head (08b3acb).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3836      +/-   ##
==========================================
+ Coverage   95.92%   95.96%   +0.04%     
==========================================
  Files        1122     1126       +4     
  Lines       35501    35786     +285     
==========================================
+ Hits        34053    34342     +289     
+ Misses       1448     1444       -4     

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

@novakzaballa novakzaballa force-pushed the chore/delete-feature-external-resources-when-github-integration-was-deleted branch from bdac2de to 8749f88 Compare April 24, 2024 15:47
@novakzaballa novakzaballa changed the title chore: Delete feature external resources when GitHub integration was deleted fix: Delete feature external resources when GitHub integration was deleted Apr 24, 2024
@novakzaballa novakzaballa requested review from a team and khvn26 and removed request for a team April 24, 2024 15:52
@@ -47,3 +48,19 @@ class Meta:
name="unique_repository_data",
)
]

@hook(BEFORE_DELETE)
def delete_feature_external_respurces(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def delete_feature_external_respurces(
def delete_feature_external_resources(

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 catch, was corrected


FeatureExternalResource.objects.filter(
feature__in=self.project.features.all(),
type__in=[
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we need to add an index on FeatureExternalResource.type?

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, I added an index

github_configuration: GithubConfiguration,
github_repository: GithubRepository,
mocker,
Copy link
Member

Choose a reason for hiding this comment

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

from pytest_mock import MockerFixture

Suggested change
mocker,
mocker: MockerFixture,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

)

FeatureExternalResource.objects.filter(
feature__in=self.project.features.all(),
Copy link
Member

Choose a reason for hiding this comment

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

I'd avoid a SELECT * here:

Suggested change
feature__in=self.project.features.all(),
feature_id__in=self.project.features.values_list("id", flat=True),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@novakzaballa novakzaballa added this pull request to the merge queue Apr 24, 2024
Merged via the queue into main with commit 576cc83 Apr 24, 2024
22 checks passed
@novakzaballa novakzaballa deleted the chore/delete-feature-external-resources-when-github-integration-was-deleted branch April 24, 2024 20:14
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.

None yet

3 participants