-
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
[WEB-2708] fix: intake module and cycle addition fixed #5890
Conversation
WalkthroughThe changes in this pull request focus on 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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- web/core/components/issues/issue-modal/base.tsx (2 hunks)
🧰 Additional context used
🔇 Additional comments (1)
web/core/components/issues/issue-modal/base.tsx (1)
7-7
: Import statement updated appropriatelyThe addition of
TBaseIssue
to the import statement is appropriate and necessary for its usage in type casting within the code.
// check if we should add issue to cycle/module | ||
if ( | ||
payload.cycle_id && | ||
payload.cycle_id !== "" && | ||
(payload.cycle_id !== cycleId || storeType !== EIssuesStoreType.CYCLE) | ||
) { | ||
await addIssueToCycle(data as TBaseIssue, payload.cycle_id); | ||
} | ||
if ( | ||
payload.module_ids && | ||
payload.module_ids.length > 0 && | ||
(!payload.module_ids.includes(moduleId?.toString()) || storeType !== EIssuesStoreType.MODULE) | ||
) { | ||
await addIssueToModule(data as TBaseIssue, payload.module_ids); | ||
} | ||
|
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.
🛠️ Refactor suggestion
Ensure proper updating of issue cycle and module associations
When updating an issue, adding it to a new cycle or modules without removing it from previous associations may lead to the issue being linked to multiple cycles or modules unintentionally. Consider modifying the code to remove the issue from its previous cycle and modules before adding it to the new ones.
Apply this diff to handle the removal of the issue from previous associations:
if (
payload.cycle_id &&
payload.cycle_id !== "" &&
(payload.cycle_id !== cycleId || storeType !== EIssuesStoreType.CYCLE)
) {
+ if (data.cycle_id && data.cycle_id !== payload.cycle_id) {
+ await removeIssueFromCycle(data as TBaseIssue, data.cycle_id);
+ }
await addIssueToCycle(data as TBaseIssue, payload.cycle_id);
}
if (
payload.module_ids &&
payload.module_ids.length > 0 &&
(!payload.module_ids.includes(moduleId?.toString()) || storeType !== EIssuesStoreType.MODULE)
) {
+ const modulesToRemove = data.module_ids?.filter(
+ (id) => !payload.module_ids.includes(id)
+ ) || [];
+ if (modulesToRemove.length > 0) {
+ await removeIssueFromModules(data as TBaseIssue, modulesToRemove);
+ }
await addIssueToModule(data as TBaseIssue, payload.module_ids);
}
Ensure you define the removeIssueFromCycle
and removeIssueFromModules
functions to handle the removal logic appropriately.
📝 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.
// check if we should add issue to cycle/module | |
if ( | |
payload.cycle_id && | |
payload.cycle_id !== "" && | |
(payload.cycle_id !== cycleId || storeType !== EIssuesStoreType.CYCLE) | |
) { | |
await addIssueToCycle(data as TBaseIssue, payload.cycle_id); | |
} | |
if ( | |
payload.module_ids && | |
payload.module_ids.length > 0 && | |
(!payload.module_ids.includes(moduleId?.toString()) || storeType !== EIssuesStoreType.MODULE) | |
) { | |
await addIssueToModule(data as TBaseIssue, payload.module_ids); | |
} | |
// check if we should add issue to cycle/module | |
if ( | |
payload.cycle_id && | |
payload.cycle_id !== "" && | |
(payload.cycle_id !== cycleId || storeType !== EIssuesStoreType.CYCLE) | |
) { | |
if (data.cycle_id && data.cycle_id !== payload.cycle_id) { | |
await removeIssueFromCycle(data as TBaseIssue, data.cycle_id); | |
} | |
await addIssueToCycle(data as TBaseIssue, payload.cycle_id); | |
} | |
if ( | |
payload.module_ids && | |
payload.module_ids.length > 0 && | |
(!payload.module_ids.includes(moduleId?.toString()) || storeType !== EIssuesStoreType.MODULE) | |
) { | |
const modulesToRemove = data.module_ids?.filter( | |
(id) => !payload.module_ids.includes(id) | |
) || []; | |
if (modulesToRemove.length > 0) { | |
await removeIssueFromModules(data as TBaseIssue, modulesToRemove); | |
} | |
await addIssueToModule(data as TBaseIssue, payload.module_ids); | |
} |
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: 0
🧹 Outside diff range and nitpick comments (1)
apiserver/plane/app/views/search/issue.py (1)
67-69
: Consistent approach for sub-issue filteringThis segment maintains consistency with the previous changes:
- The use of
filter().first()
and the conditional check align with the established pattern.- The filtering logic correctly excludes the current issue and includes only parent issues.
However, for completeness and consistency with the previous segment, consider adding a
deleted_at
check:issues = issues.filter(~Q(pk=issue_id), parent__isnull=True, deleted_at__isnull=True)This would ensure that deleted sub-issues are also excluded from the results.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- apiserver/plane/app/views/search/issue.py (1 hunks)
🧰 Additional context used
🔇 Additional comments (5)
apiserver/plane/app/views/search/issue.py (5)
45-51
: Improved error handling and filtering logicThe changes in this segment enhance the robustness of the code:
- Using
filter().first()
instead ofget()
prevents potential exceptions when the issue is not found.- The conditional check
if issue:
ensures that filtering is only applied when the issue exists.- The filtering logic correctly excludes the current issue, its parent, and its direct children from the results.
These modifications improve error handling and prevent potential issues when dealing with non-existent records.
53-65
: Enhanced filtering for issue relationshipsThis segment maintains consistency with the previous changes and introduces an important improvement:
- The use of
filter().first()
and the conditional check are consistent with the previous segment, maintaining code quality.- The filtering logic now includes
deleted_at__isnull=True
in the related issue queries. This ensures that deleted relationships are properly excluded from the results.The addition of the
deleted_at
check is a significant improvement, as it prevents deleted relationships from appearing in the search results.
74-77
: Improved cycle filtering with deletion checkThis change enhances the cycle filtering logic:
- The addition of
Q(issue_cycle__deleted_at__isnull=True)
ensures that only active (non-deleted) cycle associations are considered when excluding issues.- This improvement aligns with the changes made in the issue relationship filtering, maintaining consistency throughout the code.
The modification prevents issues from being incorrectly excluded due to deleted cycle associations, improving the accuracy of the search results.
80-83
: Consistent improvement in module filteringThis change in module filtering logic mirrors the improvements made in cycle filtering:
- The addition of
Q(issue_module__deleted_at__isnull=True)
ensures that only active (non-deleted) module associations are considered when excluding issues.- This change maintains consistency with the improvements in cycle and issue relationship filtering throughout the code.
This modification prevents issues from being incorrectly excluded due to deleted module associations, further enhancing the accuracy and reliability of the search results.
45-83
: Summary: Comprehensive improvements in issue filtering and error handlingThe changes in this file significantly enhance the robustness and accuracy of the issue search functionality:
- Improved error handling by using
filter().first()
instead ofget()
when retrieving issues.- Consistent application of conditional checks to prevent operations on non-existent issues.
- Enhanced filtering logic for issue relationships, cycles, and modules, ensuring that deleted associations are properly excluded.
These improvements align well with the PR objectives of fixing the intake module and cycle addition. They prevent potential errors and enhance the accuracy of search results by properly handling various edge cases and deleted associations.
The consistency in applying these improvements across different filtering scenarios (parent issues, related issues, sub-issues, cycles, and modules) demonstrates a thorough approach to addressing the underlying issues.
Overall, these changes contribute to a more reliable and accurate issue search functionality, which is crucial for the proper addition of modules and cycles when handling intake issues.
Summary
This PR adds modules and cycles properly while accepting an intake issue
[WEB-2708]
Summary by CodeRabbit
New Features
Bug Fixes
Chores