-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
chore: filter the deleted issues for displaying stats #5893
Conversation
WalkthroughThe changes in this pull request involve multiple modifications across various API endpoints to enhance the filtering logic for issues associated with cycles and modules. Specifically, conditions have been added to ensure that only non-deleted issues are counted or retrieved by checking the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 9
🧹 Outside diff range and nitpick comments (7)
apiserver/plane/app/views/workspace/cycle.py (1)
Line range hint
36-96
: Overall assessment: Consistent and effective implementation of deleted issue filtering.The changes in this file consistently apply the
issue_cycle__deleted_at__isnull=True
filter across all issue annotations, effectively implementing the PR objective of filtering deleted issues for accurate statistics. The implementation is clean and doesn't introduce any new complexity.Consider refactoring the repeated filter condition into a reusable Q object to reduce code duplication. For example:
from django.db.models import Q non_deleted_issue_filter = Q( issue_cycle__issue__archived_at__isnull=True, issue_cycle__issue__is_draft=False, issue_cycle__issue__deleted_at__isnull=True, issue_cycle__deleted_at__isnull=True, ) # Then use it in annotations like this: total_issues=Count("issue_cycle", filter=non_deleted_issue_filter)This refactoring would make the code more DRY and easier to maintain in the future.
apiserver/plane/app/views/workspace/module.py (2)
48-48
: Approved: Filtering out deleted issues improves data accuracy.The addition of
issue_module__deleted_at__isnull=True
to the filter ensures that only non-deleted issues are counted, which aligns with the PR objective and improves the accuracy of the total issues count.Consider extracting the common filter conditions into a separate
Q
object to improve code readability and maintainability. For example:base_filter = Q( issue_module__issue__archived_at__isnull=True, issue_module__issue__is_draft=False, issue_module__deleted_at__isnull=True, ) # Then use it in annotations like this: total_issues=Count("issue_module", filter=base_filter, distinct=True)This approach would reduce repetition and make it easier to update the filter conditions across all annotations if needed in the future.
Line range hint
1-124
: Overall assessment: Consistent and effective implementation of issue filtering.The changes in this file successfully implement the filtering of deleted issues across all annotations in the
WorkspaceModulesEndpoint
class. This improvement ensures that the module statistics accurately reflect only active issues, which aligns with the PR objective of enhancing the accuracy of displayed stats.To further improve the code:
- Consider extracting the common filter conditions into a separate
Q
object to reduce repetition and improve maintainability.- Add a comment explaining the purpose of the
issue_module__deleted_at__isnull=True
condition to enhance code readability.Example refactoring:
# Define base filter to exclude deleted and archived issues base_filter = Q( issue_module__issue__archived_at__isnull=True, issue_module__issue__is_draft=False, issue_module__deleted_at__isnull=True, # Exclude deleted issues ) # Use in annotations total_issues=Count("issue_module", filter=base_filter, distinct=True) completed_issues=Count("issue_module__issue__state__group", filter=base_filter & Q(issue_module__issue__state__group="completed"), distinct=True) # ... repeat for other issue statesThis refactoring would make the code more maintainable and easier to update if additional filtering criteria are needed in the future.
apiserver/plane/app/views/module/issue.py (1)
61-61
: LGTM! Consider adding a comment for clarity.The addition of
issue_module__deleted_at__isnull=True
effectively filters out deleted module issues, which aligns with the PR objective. This change is consistent with similar modifications in other files and improves the accuracy of the displayed statistics.Consider adding a brief comment explaining the purpose of this filter for better code readability:
# Filter out deleted module issues issue_module__deleted_at__isnull=True,apiserver/plane/bgtasks/analytic_plot_export.py (1)
Line range hint
172-185
: Improvement in data integrity for cycle detailsThe addition of
issue_cycle__deleted_at__isnull=True
to the filter conditions is a positive change. This ensures that only active (non-deleted) cycles are included in the query results, which aligns with the PR's objective of filtering out deleted issues for more accurate statistics.For consistency with the
get_module_details
function, consider moving the new condition next to theissue_cycle__cycle_id__isnull=False
condition:def get_cycle_details(slug, filters): return ( Issue.issue_objects.filter( workspace__slug=slug, **filters, issue_cycle__cycle_id__isnull=False, + issue_cycle__deleted_at__isnull=True, ) - issue_cycle__deleted_at__isnull=True, .distinct("issue_cycle__cycle_id") .order_by("issue_cycle__cycle_id") .values( "issue_cycle__cycle_id", "issue_cycle__cycle__name", ) )This minor adjustment would improve code readability and maintain consistency across similar functions.
apiserver/plane/api/views/module.py (1)
376-379
: Approved: Filtering of deleted module issuesThe addition of
issue_module__deleted_at__isnull=True
to the filter ensures that deleted module issues are excluded from the query results, improving data consistency.Consider combining the new condition with the existing filter for better readability:
Issue.issue_objects.filter( issue_module__module_id=module_id, issue_module__deleted_at__isnull=True, )This minor change doesn't affect functionality but slightly improves code readability.
apiserver/plane/app/views/module/archive.py (1)
Line range hint
60-195
: Consider refactoring repeated filters to adhere to the DRY principleThe
issue_module__deleted_at__isnull=True
filter is added multiple times across different querysets. Refactoring this filter into a variable or a reusable Q object can improve code maintainability and readability.You can define a Q object at the beginning of the method:
deleted_module_filter = Q(issue_module__deleted_at__isnull=True)And then use it in your querysets:
Issue.issue_objects.filter( state__group="cancelled", issue_module__module_id=OuterRef("pk"), ).filter(deleted_module_filter)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (13)
- apiserver/plane/api/views/cycle.py (25 hunks)
- apiserver/plane/api/views/module.py (13 hunks)
- apiserver/plane/app/views/analytic/base.py (2 hunks)
- apiserver/plane/app/views/cycle/archive.py (11 hunks)
- apiserver/plane/app/views/cycle/base.py (20 hunks)
- apiserver/plane/app/views/cycle/issue.py (1 hunks)
- apiserver/plane/app/views/module/archive.py (16 hunks)
- apiserver/plane/app/views/module/base.py (17 hunks)
- apiserver/plane/app/views/module/issue.py (1 hunks)
- apiserver/plane/app/views/workspace/cycle.py (6 hunks)
- apiserver/plane/app/views/workspace/module.py (6 hunks)
- apiserver/plane/bgtasks/analytic_plot_export.py (2 hunks)
- apiserver/plane/utils/analytics_plot.py (6 hunks)
🧰 Additional context used
🔇 Additional comments (53)
apiserver/plane/app/views/workspace/cycle.py (6)
36-36
: LGTM: Appropriate filter for non-deleted issues added.The addition of
issue_cycle__deleted_at__isnull=True
to thetotal_issues
annotation ensures that only non-deleted issues are counted, which aligns with the PR objective of filtering deleted issues for accurate statistics.
48-48
: LGTM: Consistent filter applied to completed issues.The addition of
issue_cycle__deleted_at__isnull=True
to thecompleted_issues
annotation is consistent with the previous change and ensures that only non-deleted completed issues are counted.
60-60
: LGTM: Consistent filter applied to cancelled issues.The addition of
issue_cycle__deleted_at__isnull=True
to thecancelled_issues
annotation maintains consistency with the previous changes and ensures that only non-deleted cancelled issues are counted.
72-72
: LGTM: Consistent filter applied to started issues.The addition of
issue_cycle__deleted_at__isnull=True
to thestarted_issues
annotation continues the pattern of consistency across all annotations and ensures that only non-deleted started issues are counted.
84-84
: LGTM: Consistent filter applied to unstarted issues.The addition of
issue_cycle__deleted_at__isnull=True
to theunstarted_issues
annotation maintains the consistency observed in all previous annotations and ensures that only non-deleted unstarted issues are counted.
96-96
: LGTM: Consistent filter applied to backlog issues, completing the pattern.The addition of
issue_cycle__deleted_at__isnull=True
to thebacklog_issues
annotation completes the pattern of consistency across all annotations and ensures that only non-deleted backlog issues are counted.apiserver/plane/app/views/workspace/module.py (5)
60-60
: Approved: Consistent filtering for completed issues.The addition of
issue_module__deleted_at__isnull=True
to the filter for completed issues is consistent with the change made to the total issues count. This ensures that only non-deleted completed issues are included in the count, maintaining data integrity across different issue states.
72-72
: Approved: Consistent filtering for cancelled issues.The addition of
issue_module__deleted_at__isnull=True
to the filter for cancelled issues maintains consistency with the changes made to other issue state counts. This ensures that only non-deleted cancelled issues are included in the count, preserving data accuracy across all issue states.
84-84
: Approved: Consistent filtering for started issues.The addition of
issue_module__deleted_at__isnull=True
to the filter for started issues maintains consistency with the changes made to other issue state counts. This ensures that only non-deleted started issues are included in the count, maintaining data integrity across all issue states.
96-96
: Approved: Consistent filtering for unstarted issues.The addition of
issue_module__deleted_at__isnull=True
to the filter for unstarted issues maintains consistency with the changes made to other issue state counts. This ensures that only non-deleted unstarted issues are included in the count, preserving data accuracy across all issue states.
108-108
: Approved: Consistent filtering for backlog issues and overall improvement.The addition of
issue_module__deleted_at__isnull=True
to the filter for backlog issues completes the consistent application of this condition across all issue state counts. This change, along with the similar modifications to other annotations, significantly improves the accuracy of module statistics by ensuring that deleted issues are excluded from all counts.These changes collectively address the PR objective of filtering out deleted issues for displaying accurate stats. The implementation is thorough and consistent, covering all relevant issue states (total, completed, cancelled, started, unstarted, and backlog).
apiserver/plane/utils/analytics_plot.py (7)
145-145
: LGTM: Filtering out deleted cycle issuesThis change ensures that only non-deleted issues are considered when calculating estimates for cycles, which aligns with the PR objective of filtering out deleted issues for accurate stats.
157-157
: LGTM: Filtering out deleted module issuesThis change ensures that only non-deleted issues are considered when calculating estimates for modules, which is consistent with the previous change and aligns with the PR objective of filtering out deleted issues for accurate stats.
184-184
: LGTM: Filtering out deleted cycle issues for completed issues distributionThis change ensures that only non-deleted issues are considered when calculating the completed issues distribution for cycles, which is consistent with the previous changes and aligns with the PR objective of filtering out deleted issues for accurate stats.
198-198
: LGTM: Filtering out deleted cycle issues for non-point based completed issues distributionThis change ensures that only non-deleted issues are considered when calculating the completed issues distribution for cycles (non-point based), which is consistent with the previous changes and aligns with the PR objective of filtering out deleted issues for accurate stats.
224-224
: LGTM: Filtering out deleted module issues for completed issues distributionThis change ensures that only non-deleted issues are considered when calculating the completed issues distribution for modules, which is consistent with the previous changes and aligns with the PR objective of filtering out deleted issues for accurate stats.
238-238
: LGTM: Filtering out deleted module issues for non-point based completed issues distributionThis change ensures that only non-deleted issues are considered when calculating the completed issues distribution for modules (non-point based), which is consistent with the previous changes and aligns with the PR objective of filtering out deleted issues for accurate stats.
Line range hint
145-238
: Summary: Consistent implementation of deleted issue filteringThe changes in this file consistently implement filtering of deleted issues across various queries related to cycles and modules. This improvement ensures that analytics and plots are based on active issues only, enhancing the accuracy of the displayed statistics. The implementation is correct and aligns well with the PR objective.
Great job on maintaining consistency throughout the file!
apiserver/plane/app/views/module/issue.py (1)
61-61
: Positive impact on the entire viewsetThe addition of
issue_module__deleted_at__isnull=True
in theget_queryset
method ensures that all operations performed by other methods in this viewset (such aslist
,create_module_issues
,create_issue_modules
, anddestroy
) will now work only with non-deleted module issues. This change maintains consistency across the entire viewset and aligns with the PR objective of filtering out deleted issues for displaying stats.apiserver/plane/app/views/cycle/issue.py (1)
93-96
: LGTM! Important filter added for non-deleted cycle issues.The addition of
issue_cycle__deleted_at__isnull=True
to the filter conditions is a crucial improvement. This ensures that only active (non-deleted) cycle issues are included in the queryset, which aligns perfectly with the PR objective of filtering out deleted issues for accurate stat display.This change enhances data integrity and consistency across the application, particularly when retrieving and displaying cycle-related information.
apiserver/plane/bgtasks/analytic_plot_export.py (2)
Line range hint
158-169
: Improvement in data integrity for module detailsThe addition of
issue_module__deleted_at__isnull=True
to the filter conditions is a positive change. This ensures that only active (non-deleted) modules are included in the query results, which aligns with the PR's objective of filtering out deleted issues for more accurate statistics.
Line range hint
1-585
: Overall improvement in data integrity for analyticsThe changes made to
get_module_details
andget_cycle_details
functions are consistent with the PR's objective of filtering out deleted issues for more accurate statistics. These modifications ensure that only active (non-deleted) modules and cycles are included in the query results, which will lead to more accurate analytics and exports.These changes are part of a larger effort to enhance data integrity across the codebase, as seen in similar modifications to other API endpoints and classes mentioned in the AI-generated summary. The consistency in approach across different parts of the system is commendable.
No other parts of this file were modified, and the changes maintain backward compatibility by not altering function signatures or return values. This focused approach minimizes the risk of unintended side effects while achieving the desired improvement in data accuracy.
apiserver/plane/app/views/analytic/base.py (3)
174-174
: LGTM: Filtering out deleted cyclesThis change ensures that only non-deleted cycles are included in the analytics by adding the condition
issue_cycle__deleted_at__isnull=True
. This aligns with the PR objective of filtering out deleted issues for more accurate stat display.
193-193
: LGTM: Filtering out deleted modulesThis change ensures that only non-deleted modules are included in the analytics by adding the condition
issue_module__deleted_at__isnull=True
. This is consistent with the PR objective of filtering out deleted issues for more accurate stat display.
Line range hint
174-193
: Summary: Improved data integrity for analyticsThe changes in this file enhance the
AnalyticsEndpoint
class by filtering out deleted cycles and modules from the analytics data. This improvement ensures more accurate statistics by only considering active data. The modifications are consistent with the PR objectives and similar changes in other files, contributing to a more robust analytics system.apiserver/plane/api/views/module.py (3)
74-74
: Excellent addition of deleted issue filterThe new condition
issue_module__deleted_at__isnull=True
has been consistently added to all issue count annotations. This change ensures that deleted issues are excluded from various counts (total, completed, cancelled, started, unstarted, backlog), improving the accuracy of module statistics.Also applies to: 86-86, 98-98, 110-110, 122-122, 134-134
564-564
: Consistent implementation of deleted issue filtering for archived modulesThe addition of
issue_module__deleted_at__isnull=True
to all issue count annotations in the ModuleArchiveUnarchiveAPIEndpoint is consistent with the changes made in ModuleAPIEndpoint. This ensures that archived modules also exclude deleted issues from their counts, maintaining data accuracy across the entire module lifecycle.Also applies to: 576-576, 588-588, 600-600, 612-612, 624-624
Line range hint
1-668
: Summary: Effective implementation of deleted issue filteringThe changes in this file consistently implement filtering of deleted issues across different classes and methods. This improves data accuracy for module statistics, query results, and archived modules. The modifications align well with the PR objective and maintain consistency throughout the file.
Key improvements:
- Accurate issue counts in ModuleAPIEndpoint
- Consistent query results in ModuleIssueAPIEndpoint
- Proper handling of archived modules in ModuleArchiveUnarchiveAPIEndpoint
These changes enhance the overall data integrity of the module-related operations without introducing any apparent negative impacts on existing functionality.
apiserver/plane/app/views/cycle/archive.py (4)
51-51
: Consistent filtering of non-deleted issuesThe addition of
issue_cycle__deleted_at__isnull=True
to various querysets in theget_queryset
method ensures that only non-deleted issues are considered when calculating estimates and counts. This change improves data accuracy and consistency.Also applies to: 66-66, 81-81, 96-96, 111-111, 125-125
357-357
: Consistent filtering in get method and distribution calculationsThe addition of
issue_cycle__deleted_at__isnull=True
to the querysets in theget
method and distribution calculations ensures that only non-deleted issues are considered. This change maintains consistency with the modifications in theget_queryset
method and improves the overall data integrity of the API response.Also applies to: 412-412, 470-470, 526-526, 597-597
Line range hint
51-597
: Overall improvement in data accuracy for cycle statisticsThe changes made to this file consistently implement filtering of deleted issues across all relevant queries in the
CycleArchiveUnarchiveEndpoint
class. This enhancement aligns well with the PR objectives and should significantly improve the accuracy of displayed cycle statistics by excluding deleted issues from all calculations and data retrievals.Some key points:
- Consistent application of
issue_cycle__deleted_at__isnull=True
filter across different querysets.- Improved data integrity in estimate calculations, issue counts, and distribution data.
- Enhanced accuracy in API responses for cycle-related information.
These changes contribute to a more reliable and accurate representation of cycle data in the application.
Line range hint
1-697
: LGTM! Approved changes for improved cycle data accuracyThe modifications in this file are well-implemented and consistent throughout the
CycleArchiveUnarchiveEndpoint
class. They effectively address the PR objective of filtering deleted issues for displaying stats. The changes improve data accuracy and integrity without introducing any significant performance or security concerns.Key improvements:
- Consistent filtering of deleted issues across all relevant queries.
- Enhanced accuracy in cycle statistics, estimates, and distribution data.
- Improved API response integrity for cycle-related information.
These changes are approved and ready for merging.
apiserver/plane/app/views/module/base.py (8)
88-89
: LGTM: Filtering out deleted issues for cancelled count.This change correctly ensures that only non-deleted issues are counted as cancelled issues, aligning with the PR objective.
98-99
: LGTM: Filtering out deleted issues for completed count.This change correctly ensures that only non-deleted issues are counted as completed issues, maintaining consistency with the PR objective.
108-109
: LGTM: Filtering out deleted issues for started count.This change correctly ensures that only non-deleted issues are counted as started issues, maintaining consistency with the PR objective and previous changes.
118-119
: LGTM: Consistent filtering of deleted issues across all issue counts.These changes correctly ensure that only non-deleted issues are counted for unstarted, backlog, and total issues. This maintains consistency with the PR objective and previous changes.
Also applies to: 128-129, 137-138
148-149
: LGTM: Consistent filtering of deleted issues for estimate point calculations.These changes correctly ensure that only non-deleted issues are considered for various estimate point calculations. This maintains consistency with the PR objective and previous changes across different issue states and total estimates.
Also applies to: 163-164, 178-179, 193-194, 208-209, 223-224
463-464
: LGTM: Filtering out deleted sub-issues in retrieve method.This change correctly ensures that only non-deleted sub-issues are retrieved in the
retrieve
method, maintaining consistency with the PR objective and previous changes.
493-494
: LGTM: Consistent filtering of deleted issues for distribution calculations.These changes correctly ensure that only non-deleted issues are considered for various distribution calculations in the
retrieve
method. This maintains consistency with the PR objective and previous changes across different types of distributions (assignees and labels).Also applies to: 559-560, 611-612, 681-682
Line range hint
1-963
: Overall assessment: Comprehensive and consistent implementation of deleted issue filtering.The changes in this file thoroughly implement the filtering of deleted issues across various queries and methods. This consistent approach ensures that all statistics and retrievals exclude deleted issues, aligning perfectly with the PR objective. The implementation covers issue counts, estimate points, sub-issues, and distribution calculations, providing a comprehensive solution.
apiserver/plane/app/views/module/archive.py (3)
495-495
: Confirm that issue counts exclude deleted modulesAt line 495, the filter
issue_module__deleted_at__isnull=True
is added to the assignee distribution queryset. Ensure that this filter correctly excludes issues from deleted modules.
565-565
: Confirm that label distributions exclude deleted modulesAt line 565, the filter
issue_module__deleted_at__isnull=True
is added to the label distribution queryset. Verify that the label statistics accurately reflect only active modules.
376-376
: Verify that all issue queries include the deleted module filterEnsure that the
issue_module__deleted_at__isnull=True
filter is applied in all queries fetching issues to prevent inclusion of deleted modules' issues.Use the following script to find any missing filters:
#!/bin/bash # Description: Check for missing deleted_module_filter in Issue queries # Expected Result: All Issue queries should include the deleted_module_filter rg -A 5 'Issue\.issue_objects\.filter\(' apiserver/plane/app/views/ | \ grep -B 5 -A 10 'issue_module__module_id' | \ grep -v 'issue_module__deleted_at__isnull=True'apiserver/plane/api/views/cycle.py (8)
81-81
: Correctly excluded deleted issues from counts inCycleAPIEndpoint
The addition of
issue_cycle__deleted_at__isnull=True
to the filters in the annotations ensures that deleted issues are excluded from the counts oftotal_issues
,completed_issues
,cancelled_issues
,started_issues
,unstarted_issues
, andbacklog_issues
. This aligns with the objective to enhance the accuracy of displayed statistics.Also applies to: 92-92, 103-103, 114-114, 125-125, 136-136
446-446
: Consistently filtered out deleted issues inCycleArchiveUnarchiveAPIEndpoint
By including
issue_cycle__deleted_at__isnull=True
in the annotations, the counts for archived cycles now accurately reflect only active issues, excluding any that have been deleted.Also applies to: 457-457, 468-468, 479-479, 490-490, 501-501, 515-515, 526-526
632-635
: Ensured only active issues are retrieved inCycleIssueAPIEndpoint
The addition of
issue_cycle__deleted_at__isnull=True
in the queryset filters ensures that only non-deleted issues are listed when fetching issues related to a cycle. This enhances data integrity and user experience.
832-832
: Excluded deleted issues during issue transfer inTransferCycleIssueAPIEndpoint
Including
issue_cycle__deleted_at__isnull=True
in the filters when annotating issue counts ensures that deleted issues are not considered during the transfer process between cycles.Also applies to: 843-843, 854-854, 865-865, 876-876, 887-887
904-904
: Accurate estimate calculations by excluding deleted issuesAdding
issue_cycle__deleted_at__isnull=True
to the filters ensures that estimate calculations for assignees are based solely on active issues, improving the accuracy of the assignee estimate data.
980-980
: Corrected label estimate distribution to exclude deleted issuesBy filtering out deleted issues using
issue_cycle__deleted_at__isnull=True
, the label estimate distribution now accurately represents estimates from active issues only.
1042-1042
: Improved assignee distribution accuracyThe inclusion of
issue_cycle__deleted_at__isnull=True
ensures that the assignee distribution computations exclude deleted issues, providing more precise analytics.
1121-1121
: Updated label distribution to reflect active issuesBy adding
issue_cycle__deleted_at__isnull=True
to the filters, the label distribution now correctly accounts for only non-deleted issues, enhancing the reliability of the data.apiserver/plane/app/views/cycle/base.py (2)
1374-1374
: Check for missing deletion filters in issue analyticsWhen generating assignee distributions for issues, verify that the filters include
issue_cycle__issue__deleted_at__isnull=True
to exclude deleted issues.Run this script to identify potential omissions:
#!/bin/bash # Description: Identify issue analytics without proper deletion checks. # Expected: All issue analytics should filter out deleted issues. # Search for analytics queries missing `issue__deleted_at__isnull=True` rg -A5 'issue_objects\.filter\(' | rg 'issue_cycle__cycle_id=' | rg -v 'issue__deleted_at__isnull=True'
682-682
: Verify consistency in issue filteringWhile filtering issues for estimate calculations, ensure that both
issue_cycle__issue__deleted_at__isnull=True
andissue_cycle__deleted_at__isnull=True
are included to exclude deleted issues and issue cycles.Run the following script to check for consistency across the codebase:
✅ Verification successful
Consistency in issue filtering verified.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for filters missing issue deletion checks. # Expected: All querysets involving issues should include both deletion checks. # Search for issue querysets missing `issue__deleted_at__isnull=True` rg -A5 'Issue\.issue_objects\.filter\(' | rg -v 'issue__deleted_at__isnull=True'Length of output: 3326
@@ -337,6 +349,7 @@ def get(self, request, slug, project_id, pk=None): | |||
project_id=self.kwargs.get("project_id"), | |||
parent__isnull=False, | |||
issue_module__module_id=pk, | |||
issue_module__deleted_at__isnull=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.
💡 Codebase verification
Inconsistent Application of deleted_at
Filter Detected
The following queries are missing the issue_module__deleted_at__isnull=True
filter:
apiserver/plane/app/views/module/base.py
apiserver/plane/app/views/module/archive.py
apiserver/plane/app/views/module/issue.py
apiserver/plane/app/views/analytic/base.py
Please ensure that all Issue.issue_objects.filter
queries include the issue_module__deleted_at__isnull=True
filter to maintain data integrity.
🔗 Analysis chain
Ensure consistency in filtering deleted modules
In line 352, the filter issue_module__deleted_at__isnull=True
is added. Verify that all related queries consistently apply this filter to maintain data integrity.
Run the following script to check for any occurrences where the filter might be missing:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Find Issue queries without the deleted_module_filter
# Expected Result: No Issue queries lacking the deleted_module_filter
rg -A 5 'Issue\.issue_objects\.filter\(' apiserver/plane/app/views/ | \
grep -B 5 -A 10 'issue_module__module_id' | \
grep -v 'issue_module__deleted_at__isnull=True'
Length of output: 17153
@@ -102,7 +102,7 @@ def get_queryset(self): | |||
filter=Q( | |||
issue_cycle__issue__archived_at__isnull=True, | |||
issue_cycle__issue__is_draft=False, | |||
issue_cycle__issue__deleted_at__isnull=True, | |||
issue_cycle__deleted_at__isnull=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.
Consider adding issue deletion check to the filter
In the total_issues
annotation, you've added a filter for issue_cycle__deleted_at__isnull=True
. To ensure that deleted issues themselves are also excluded, consider adding issue_cycle__issue__deleted_at__isnull=True
to the filter conditions.
Apply this diff to include the issue deletion check:
issue_cycle__issue__archived_at__isnull=True,
issue_cycle__issue__is_draft=False,
+ issue_cycle__issue__deleted_at__isnull=True,
issue_cycle__deleted_at__isnull=True,
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
issue_cycle__deleted_at__isnull=True, | |
issue_cycle__issue__archived_at__isnull=True, | |
issue_cycle__issue__is_draft=False, | |
issue_cycle__issue__deleted_at__isnull=True, | |
issue_cycle__deleted_at__isnull=True, |
@@ -1220,6 +1238,7 @@ | |||
issue_cycle__issue__archived_at__isnull=True, | |||
issue_cycle__issue__is_draft=False, | |||
issue_cycle__issue__deleted_at__isnull=True, | |||
issue_cycle__deleted_at__isnull=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.
Ensure deleted issues are excluded in cycle analytics
In the CycleAnalyticsEndpoint
, include issue_cycle__issue__deleted_at__isnull=True
in the filters to ensure accurate analytics by excluding deleted issues.
Apply this diff:
issue_cycle__issue__deleted_at__isnull=True,
+ issue_cycle__deleted_at__isnull=True,
Committable suggestion was skipped due to low confidence.
@@ -1408,6 +1430,7 @@ | |||
label_distribution = ( | |||
Issue.issue_objects.filter( | |||
issue_cycle__cycle_id=cycle_id, | |||
issue_cycle__deleted_at__isnull=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.
Include issue deletion check in label distribution
In the label distribution calculation, ensure that deleted issues are excluded by adding issue_cycle__issue__deleted_at__isnull=True
to the filters.
Update the filter as follows:
issue_cycle__cycle_id=cycle_id,
+ issue_cycle__issue__deleted_at__isnull=True,
issue_cycle__deleted_at__isnull=True,
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
issue_cycle__deleted_at__isnull=True, | |
issue_cycle__cycle_id=cycle_id, | |
issue_cycle__issue__deleted_at__isnull=True, | |
issue_cycle__deleted_at__isnull=True, |
@@ -114,7 +114,7 @@ | |||
issue_cycle__issue__state__group="completed", | |||
issue_cycle__issue__archived_at__isnull=True, | |||
issue_cycle__issue__is_draft=False, | |||
issue_cycle__issue__deleted_at__isnull=True, | |||
issue_cycle__deleted_at__isnull=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.
Include issue deletion check in completed issues filter
When annotating completed_issues
, consider adding issue_cycle__issue__deleted_at__isnull=True
to exclude deleted issues from the count.
Apply this diff:
issue_cycle__issue__state__group="completed",
issue_cycle__issue__archived_at__isnull=True,
issue_cycle__issue__is_draft=False,
+ issue_cycle__issue__deleted_at__isnull=True,
issue_cycle__deleted_at__isnull=True,
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
issue_cycle__deleted_at__isnull=True, | |
issue_cycle__issue__state__group="completed", | |
issue_cycle__issue__archived_at__isnull=True, | |
issue_cycle__issue__is_draft=False, | |
issue_cycle__issue__deleted_at__isnull=True, | |
issue_cycle__deleted_at__isnull=True, |
@@ -1074,6 +1085,7 @@ | |||
Issue.issue_objects.filter( | |||
estimate_point__estimate__type="points", | |||
issue_cycle__cycle_id=cycle_id, | |||
issue_cycle__deleted_at__isnull=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.
Add issue deletion check to estimate aggregation
In the CycleProgressEndpoint
, when aggregating estimates, consider adding issue_cycle__issue__deleted_at__isnull=True
to exclude deleted issues from the calculations.
Proposed update:
issue_cycle__cycle_id=cycle_id,
+ issue_cycle__issue__deleted_at__isnull=True,
issue_cycle__deleted_at__isnull=True,
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
issue_cycle__deleted_at__isnull=True, | |
issue_cycle__cycle_id=cycle_id, | |
issue_cycle__issue__deleted_at__isnull=True, | |
issue_cycle__deleted_at__isnull=True, |
@@ -601,6 +602,7 @@ | |||
filter=Q( | |||
issue_cycle__issue__archived_at__isnull=True, | |||
issue_cycle__issue__is_draft=False, | |||
issue_cycle__deleted_at__isnull=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.
Ensure deleted issues are excluded in total issues count
In the TransferCycleIssueEndpoint
, when annotating total_issues
, consider adding issue_cycle__issue__deleted_at__isnull=True
to exclude deleted issues from the total count.
Proposed change:
issue_cycle__issue__archived_at__isnull=True,
issue_cycle__issue__is_draft=False,
+ issue_cycle__issue__deleted_at__isnull=True,
issue_cycle__deleted_at__isnull=True,
Committable suggestion was skipped due to low confidence.
@@ -612,6 +614,7 @@ | |||
issue_cycle__issue__archived_at__isnull=True, | |||
issue_cycle__issue__is_draft=False, | |||
issue_cycle__issue__deleted_at__isnull=True, | |||
issue_cycle__deleted_at__isnull=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.
Include issue deletion check in completed issues count
For completed_issues
annotation, add issue_cycle__issue__deleted_at__isnull=True
to ensure deleted issues are not counted.
Apply this diff:
issue_cycle__issue__state__group="completed",
issue_cycle__issue__archived_at__isnull=True,
issue_cycle__issue__is_draft=False,
issue_cycle__issue__deleted_at__isnull=True,
+ issue_cycle__deleted_at__isnull=True,
Committable suggestion was skipped due to low confidence.
@@ -398,6 +398,7 @@ | |||
project_id=self.kwargs.get("project_id"), | |||
parent__isnull=False, | |||
issue_cycle__cycle_id=pk, | |||
issue_cycle__deleted_at__isnull=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.
Add issue deletion check to sub-issues filter
In the retrieve
method, when fetching sub_issues
, ensure that deleted issues are excluded by adding deleted_at__isnull=True
to the filter.
Update the filter condition as follows:
sub_issues=Issue.issue_objects.filter(
project_id=self.kwargs.get("project_id"),
parent__isnull=False,
issue_cycle__cycle_id=pk,
+ deleted_at__isnull=True,
issue_cycle__deleted_at__isnull=True,
)
Committable suggestion was skipped due to low confidence.
chore:
Summary by CodeRabbit
New Features
Bug Fixes
Documentation