Conversation
WalkthroughThe pull request modifies 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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
web/core/store/inbox/project-inbox.store.ts (1)
Line range hint
142-166: Consider refactoring the status filtering logic for better maintainabilityThe status filtering logic in the
filteredInboxIssueIdsgetter is complex and mixes multiple concerns. Consider splitting it into smaller, more focused functions.Here's a suggested refactor:
- get filteredInboxIssueIds() { - let appliedFilters = - this.currentTab === EInboxIssueCurrentTab.OPEN - ? [EInboxIssueStatus.PENDING, EInboxIssueStatus.SNOOZED] - : [EInboxIssueStatus.ACCEPTED, EInboxIssueStatus.DECLINED, EInboxIssueStatus.DUPLICATE]; - appliedFilters = appliedFilters.filter((filter) => this.inboxFilters?.status?.includes(filter)); - const currentTime = new Date().getTime(); - - return this.currentTab === EInboxIssueCurrentTab.OPEN - ? this.inboxIssueIds.filter((id) => { - if (appliedFilters.length == 2) return true; - if (appliedFilters[0] === EInboxIssueStatus.SNOOZED) - return ( - this.inboxIssues[id].status === EInboxIssueStatus.SNOOZED && - currentTime < new Date(this.inboxIssues[id].snoozed_till!).getTime() - ); - if (appliedFilters[0] === EInboxIssueStatus.PENDING) - return ( - appliedFilters.includes(this.inboxIssues[id].status) || - (this.inboxIssues[id].status === EInboxIssueStatus.SNOOZED && - currentTime > new Date(this.inboxIssues[id].snoozed_till!).getTime()) - ); - }) - : this.inboxIssueIds.filter((id) => appliedFilters.includes(this.inboxIssues[id].status)); + private isSnoozeExpired(snoozedTill: string): boolean { + return new Date().getTime() > new Date(snoozedTill).getTime(); + } + + private getDefaultStatusFilters(): EInboxIssueStatus[] { + return this.currentTab === EInboxIssueCurrentTab.OPEN + ? [EInboxIssueStatus.PENDING, EInboxIssueStatus.SNOOZED] + : [EInboxIssueStatus.ACCEPTED, EInboxIssueStatus.DECLINED, EInboxIssueStatus.DUPLICATE]; + } + + private filterIssueByStatus(id: string, appliedFilters: EInboxIssueStatus[]): boolean { + const issue = this.inboxIssues[id]; + + if (this.currentTab !== EInboxIssueCurrentTab.OPEN) { + return appliedFilters.includes(issue.status); + } + + if (appliedFilters.length === 2) return true; + + if (appliedFilters[0] === EInboxIssueStatus.SNOOZED) { + return ( + issue.status === EInboxIssueStatus.SNOOZED && + !this.isSnoozeExpired(issue.snoozed_till!) + ); + } + + if (appliedFilters[0] === EInboxIssueStatus.PENDING) { + return ( + appliedFilters.includes(issue.status) || + (issue.status === EInboxIssueStatus.SNOOZED && + this.isSnoozeExpired(issue.snoozed_till!)) + ); + } + + return false; + } + + get filteredInboxIssueIds() { + const defaultFilters = this.getDefaultStatusFilters(); + const appliedFilters = defaultFilters.filter( + (filter) => this.inboxFilters?.status?.includes(filter) + ); + + return this.inboxIssueIds.filter((id) => + this.filterIssueByStatus(id, appliedFilters) + ); }This refactor:
- Splits the logic into smaller, focused functions
- Makes the code more readable and maintainable
- Makes it easier to test individual pieces of logic
- Improves reusability of the status filtering logic
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
web/core/store/inbox/project-inbox.store.ts(1 hunks)
🔇 Additional comments (1)
web/core/store/inbox/project-inbox.store.ts (1)
391-391: LGTM! This change correctly fixes the intake status count.
The modification ensures that only explicitly selected status filters are used in the API query, which will accurately reflect the status filters applied in the intake header.
Let's verify the status filtering logic:
✅ Verification successful
Based on the results from the shell scripts, I can now generate the final response as we have sufficient evidence about the status filtering implementation:
The status filtering change is correct and safe.
The search results confirm that:
- The status filtering logic in
filteredInboxIssueIdsproperly handles both PENDING and SNOOZED states with appropriate time-based conditions - The direct use of
inboxFilters?.statusin the API query is consistent with the UI filter implementation ininbox-filtercomponents - No other parts of the codebase combine status with SNOOZED in a way that would be affected by this change
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the status filtering implementation across the codebase
# Expected results: No instances of combining status with SNOOZED outside of filteredInboxIssueIds
# Check for any other instances where status might be combined with SNOOZED
rg -A 5 "status.*SNOOZED" --type ts
# Check the complete status filtering implementation
ast-grep --pattern 'status = $status' --type ts
Length of output: 2000
Script:
#!/bin/bash
# Let's try a different pattern to check status assignments and filtering logic
# Check for status filtering in the inbox store
rg -A 10 "inboxFilters\?\.status" --type ts
# Check for status-related filtering logic
ast-grep --pattern 'status: $status'
# Check for any direct status assignments
ast-grep --pattern 'status = $_'
Length of output: 8258
Summary
This PR fixes the total count in intake header based on the status filters
[WEB-2758]
Summary by CodeRabbit
New Features
Bug Fixes