-
Notifications
You must be signed in to change notification settings - Fork 429
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
fix: Delete feature external resources when GitHub integration was deleted #3836
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Uffizzi Preview |
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
bdac2de
to
8749f88
Compare
api/integrations/github/models.py
Outdated
@@ -47,3 +48,19 @@ class Meta: | |||
name="unique_repository_data", | |||
) | |||
] | |||
|
|||
@hook(BEFORE_DELETE) | |||
def delete_feature_external_respurces( |
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.
def delete_feature_external_respurces( | |
def delete_feature_external_resources( |
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.
Good catch, was corrected
|
||
FeatureExternalResource.objects.filter( | ||
feature__in=self.project.features.all(), | ||
type__in=[ |
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 you think we need to add an index on FeatureExternalResource.type
?
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.
Good idea, I added an index
github_configuration: GithubConfiguration, | ||
github_repository: GithubRepository, | ||
mocker, |
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.
from pytest_mock import MockerFixture
mocker, | |
mocker: MockerFixture, |
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.
Added
api/integrations/github/models.py
Outdated
) | ||
|
||
FeatureExternalResource.objects.filter( | ||
feature__in=self.project.features.all(), |
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.
I'd avoid a SELECT *
here:
feature__in=self.project.features.all(), | |
feature_id__in=self.project.features.values_list("id", flat=True), |
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.
Done.
…deleted
Thanks for submitting a PR! Please check the boxes below:
pre-commit
to check lintingdocs/
if required so people know about the feature!Changes
How did you test this code?