This repository was archived by the owner on Jun 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
fix: parameter filtering takes branch into account #913
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| Avg, | ||
| F, | ||
| Q, | ||
| QuerySet, | ||
| Sum, | ||
| Value, | ||
| ) | ||
|
|
@@ -298,6 +299,17 @@ | |
| return rows[left:] | ||
|
|
||
|
|
||
| def get_relevant_totals( | ||
| repoid: int, branch: str | None, since: dt.datetime | ||
| ) -> QuerySet: | ||
| if branch: | ||
| return DailyTestRollup.objects.filter( | ||
| repoid=repoid, date__gt=since, branch=branch | ||
| ) | ||
| else: | ||
| return DailyTestRollup.objects.filter(repoid=repoid, date__gt=since) | ||
|
|
||
|
|
||
| def generate_test_results( | ||
| ordering: str, | ||
| ordering_direction: str, | ||
|
|
@@ -341,7 +353,7 @@ | |
| test_ids: set[str] | None = None | ||
|
|
||
| if term is not None: | ||
| totals = DailyTestRollup.objects.filter(repoid=repoid, date__gt=since) | ||
| totals = get_relevant_totals(repoid, branch, since) | ||
|
|
||
| totals = totals.filter(test__name__icontains=term).values("test_id") | ||
|
|
||
|
|
@@ -357,19 +369,21 @@ | |
| test_ids = test_ids & filtered_test_ids if test_ids else filtered_test_ids | ||
|
|
||
| if parameter is not None: | ||
| totals = get_relevant_totals(repoid, branch, since) | ||
| match parameter: | ||
| case GENERATE_TEST_RESULT_PARAM.FLAKY: | ||
| flakes = Flake.objects.filter( | ||
| Q(repository_id=repoid) | ||
| & (Q(end_date__date__isnull=True) | Q(end_date__date__gt=since)) | ||
| flaky_test_ids = ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. being able to have a generalized pattern for all these makes it so much easier to read |
||
| totals.values("test") | ||
| .annotate(flaky_fail_count_sum=Sum("flaky_fail_count")) | ||
| .filter(flaky_fail_count_sum__gt=0) | ||
| .values("test_id") | ||
| ) | ||
| flaky_test_id_set = {test["test_id"] for test in flaky_test_ids} | ||
|
|
||
| flaky_test_ids = set([flake.test_id for flake in flakes]) | ||
|
|
||
| test_ids = test_ids & flaky_test_ids if test_ids else flaky_test_ids | ||
| test_ids = ( | ||
| test_ids & flaky_test_id_set if test_ids else flaky_test_id_set | ||
| ) | ||
| case GENERATE_TEST_RESULT_PARAM.FAILED: | ||
| totals = DailyTestRollup.objects.filter(repoid=repoid, date__gt=since) | ||
|
|
||
| failed_test_ids = ( | ||
| totals.values("test") | ||
| .annotate(fail_count_sum=Sum("fail_count")) | ||
|
|
@@ -382,8 +396,6 @@ | |
| test_ids & failed_test_id_set if test_ids else failed_test_id_set | ||
| ) | ||
| case GENERATE_TEST_RESULT_PARAM.SKIPPED: | ||
| totals = DailyTestRollup.objects.filter(repoid=repoid, date__gt=since) | ||
|
|
||
| skipped_test_ids = ( | ||
| totals.values("test") | ||
| .annotate( | ||
|
|
@@ -400,8 +412,6 @@ | |
| test_ids & skipped_test_id_set if test_ids else skipped_test_id_set | ||
| ) | ||
| case GENERATE_TEST_RESULT_PARAM.SLOWEST: | ||
| totals = DailyTestRollup.objects.filter(repoid=repoid, date__gt=since) | ||
|
|
||
| num_tests = totals.distinct("test_id").count() | ||
|
|
||
| slowest_test_ids = ( | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
love this refactor!