Skip to content
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-3102]fix: transfer issues count #6384

Merged
merged 6 commits into from
Jan 15, 2025
Merged

Conversation

vamsikrishnamathala
Copy link
Collaborator

@vamsikrishnamathala vamsikrishnamathala commented Jan 13, 2025

Description

Added cancelled issues count to pending issues.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

References

WEB-3102

Summary by CodeRabbit

Release Notes

  • New Features

    • Added pending_issues property to track unfinished issues in cycles.
    • Enhanced cycle management with more precise issue tracking.
  • Improvements

    • Updated cycle details retrieval to show more accurate issue counts.
    • Refined issue transfer logic across multiple components, including updates to modals and action components.
  • Technical Updates

    • Improved data structure for cycle-related information.
    • Optimized cycle and issue tracking mechanisms.

Copy link
Contributor

coderabbitai bot commented Jan 13, 2025

Walkthrough

The pull request introduces a comprehensive update to how pending issues are tracked and displayed across the Plane application. The changes span multiple components and files, focusing on replacing the manual calculation of transferable issues with a direct pending_issues property. This modification affects the cycle management workflow, ensuring a more accurate representation of issue status by leveraging a server-side annotation that counts issues in specific states.

Changes

File Change Summary
web/core/components/cycles/list/cycle-list-item-action.tsx Removed manual transferableIssuesCount calculation; updated logic to use cycleDetails.pending_issues for display.
web/core/components/cycles/quick-actions.tsx Conditionally rendered EndCycleModal and updated to use cycleDetails.pending_issues for issue transfer count.
apiserver/plane/app/views/cycle/base.py Added server-side annotation for pending_issues, counting issues in backlog, unstarted, and started states.
packages/types/src/cycle/cycle.d.ts Added pending_issues: number property to ICycle interface.
web/core/components/cycles/transfer-issues-modal.tsx Replaced fetchCycleDetails function calls with fetchActiveCycleProgress.

Sequence Diagram

sequenceDiagram
    participant API as API Server
    participant Frontend as Frontend Components
    participant Cycle as Cycle Management

    API->>API: Annotate cycles with pending_issues
    Frontend->>API: Request cycle list
    API-->>Frontend: Return cycles with pending_issues
    Frontend->>Cycle: Render transfer issues UI
    Cycle->>Frontend: Display pending issues count
Loading

Possibly related PRs

Suggested reviewers

  • SatishGandham
  • rahulramesha
  • gurusainath

Poem

🐰 Hopping through cycles with glee,
Pending issues now clear to see!
No more math, just pure delight,
Counting issues, getting it right!
A rabbit's view of workflow neat 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c68e36c and 1a7ff72.

📒 Files selected for processing (1)
  • web/core/components/cycles/list/cycle-list-item-action.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/cycles/list/cycle-list-item-action.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint-apiserver
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
web/core/components/cycles/list/cycle-list-item-action.tsx (1)

84-88: LGTM! Consider extracting the calculation to a utility function.

The calculation correctly accounts for cancelled issues and is consistent with the implementation in quick-actions.tsx.

Since this calculation is used in multiple components, consider extracting it to a utility function:

+// utils/cycle.ts
+export const getTransferableIssuesCount = (cycle: ICycle): number =>
+  cycle ? cycle.total_issues - cycle.completed_issues - (cycle.progress_snapshot?.cancelled_issues || 0) : 0;

-const transferableIssuesCount = cycleDetails
-  ? cycleDetails.total_issues -
-    cycleDetails.completed_issues -
-    (cycleDetails.progress_snapshot?.cancelled_issues || 0)
-  : 0;
+const transferableIssuesCount = getTransferableIssuesCount(cycleDetails);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ade4d29 and d0b8e9c.

📒 Files selected for processing (2)
  • web/core/components/cycles/list/cycle-list-item-action.tsx (1 hunks)
  • web/core/components/cycles/quick-actions.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (1)
web/core/components/cycles/quick-actions.tsx (1)

45-49: LGTM! Verify the impact on cycle transfers.

The calculation now correctly accounts for cancelled issues using safe access patterns. This provides a more accurate count of transferable issues.

Let's verify the usage of this transferable count:

✅ Verification successful

Verified: The transferable issues count change is safe

The count is used as a prop in the EndCycleModal component and doesn't affect the actual transfer functionality implemented in TransferIssuesModal. The improved calculation provides a more accurate representation of transferable issues by excluding cancelled ones.

Note: There's a spelling inconsistency between "transferable" and "transferrable" in the codebase that might be worth standardizing in a future update.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for components using transferableIssuesCount
rg -l "transferableIssuesCount|transferrableIssuesCount" --type tsx

# Search for any cycle transfer related functionality
ast-grep --pattern 'function $FUNC($ARGS) {
  $$$
  transfer
  $$$
}'

Length of output: 169


Script:

#!/bin/bash
# Search with correct file type and both spelling variants
rg -t ts -t tsx "transfer(r)?ableIssuesCount" -l

# Search for cycle transfer related code with context
rg -t ts -t tsx "(endCycle|transferIssues|moveToCycle)" -B 2 -A 2

# Look for modal components that might use the count
fd -e tsx -e ts "modal" --exec grep -l "Issues"

Length of output: 875


Script:

#!/bin/bash
# Check content of cycle-related modal components
cat "./web/ce/components/cycles/end-cycle/modal.tsx" "./web/core/components/cycles/transfer-issues-modal.tsx"

# Search for transfer-related code in these specific files
rg "transfer" "./web/ce/components/cycles/end-cycle/modal.tsx" "./web/core/components/cycles/transfer-issues-modal.tsx"

# Look for the count variable usage
rg "Issues(Count|Number)" "./web/ce/components/cycles/end-cycle/modal.tsx" "./web/core/components/cycles/transfer-issues-modal.tsx"

Length of output: 9013

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
web/core/store/cycle.store.ts (1)

371-381: Consider improving readability with early return.

The implementation correctly calculates pending issues by including cancelled issues in the calculation. However, the code can be made more readable with an early return pattern.

Here's a suggested improvement:

  getPendingIssueCount = (cycleId: string) => {
-   let pending_issues = 0;
    const cycleDetails = this.cycleMap[cycleId];
-   if (!cycleDetails) return pending_issues;
+   if (!cycleDetails) return 0;
-   pending_issues =
-     cycleDetails.total_issues -
-     cycleDetails.completed_issues -
-     (cycleDetails.progress_snapshot?.cancelled_issues || 0);
-
-   return pending_issues;
+   return cycleDetails.total_issues -
+     cycleDetails.completed_issues -
+     (cycleDetails.progress_snapshot?.cancelled_issues || 0);
  };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0b8e9c and 7a91cc1.

📒 Files selected for processing (3)
  • web/core/components/cycles/list/cycle-list-item-action.tsx (2 hunks)
  • web/core/components/cycles/quick-actions.tsx (1 hunks)
  • web/core/store/cycle.store.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/cycles/list/cycle-list-item-action.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (3)
web/core/store/cycle.store.ts (1)

59-59: LGTM!

The method signature is correctly added to the interface.

web/core/components/cycles/quick-actions.tsx (2)

39-39: LGTM!

The hook destructuring is correctly updated to include the new getPendingIssueCount method.


45-45: LGTM!

The calculation of transferableIssuesCount is correctly updated to use the new getPendingIssueCount method, which includes cancelled issues in the calculation.

@vamsikrishnamathala vamsikrishnamathala marked this pull request as draft January 15, 2025 07:02
@vamsikrishnamathala vamsikrishnamathala marked this pull request as ready for review January 15, 2025 07:16
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (2)
apiserver/plane/app/views/cycle/base.py (2)

140-140: Fix line length to comply with PEP 8.

The line exceeds the PEP 8 limit of 88 characters.

-                        issue_cycle__issue__state__group__in=["backlog", "unstarted", "started"],
+                        issue_cycle__issue__state__group__in=[
+                            "backlog",
+                            "unstarted",
+                            "started"
+                        ],
🧰 Tools
🪛 Ruff (0.8.2)

140-140: Line too long (97 > 88)

(E501)


Line range hint 586-586: Fix line length to comply with PEP 8.

The line exceeds the PEP 8 limit of 88 characters.

-                    avatar_url=Case(When(assignees__avatar_asset__isnull=False, then=Concat(Value("/api/assets/v2/static/"), "assignees__avatar_asset", Value("/"),),),
+                    avatar_url=Case(
+                        When(
+                            assignees__avatar_asset__isnull=False,
+                            then=Concat(
+                                Value("/api/assets/v2/static/"),
+                                "assignees__avatar_asset",
+                                Value("/"),
+                            ),
+                        ),
🧰 Tools
🪛 Ruff (0.8.2)

140-140: Line too long (97 > 88)

(E501)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a91cc1 and c68e36c.

📒 Files selected for processing (5)
  • apiserver/plane/app/views/cycle/base.py (3 hunks)
  • packages/types/src/cycle/cycle.d.ts (2 hunks)
  • web/core/components/cycles/list/cycle-list-item-action.tsx (2 hunks)
  • web/core/components/cycles/quick-actions.tsx (1 hunks)
  • web/core/components/cycles/transfer-issues-modal.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/core/components/cycles/quick-actions.tsx
  • web/core/components/cycles/list/cycle-list-item-action.tsx
🧰 Additional context used
🪛 Ruff (0.8.2)
apiserver/plane/app/views/cycle/base.py

140-140: Line too long (97 > 88)

(E501)

🪛 GitHub Actions: Build and Lint on Pull Request
apiserver/plane/app/views/cycle/base.py

[error] 586-586: Line too long (146 > 88 characters)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint-apiserver
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
packages/types/src/cycle/cycle.d.ts (2)

107-107: LGTM! The new pending_issues property aligns with backend changes.

The addition of pending_issues to the ICycle interface correctly reflects the backend changes in CycleViewSet where pending issues are now counted.


124-124: LGTM! Type definition formatting is clean.

The SelectCycleType formatting change improves readability without affecting functionality.

web/core/components/cycles/transfer-issues-modal.tsx (1)

60-61: LGTM! Function name change better reflects its purpose.

The replacement of fetchCycleDetails with fetchActiveCycleProgress is more descriptive and aligns with the new pending issues functionality.

apiserver/plane/app/views/cycle/base.py (1)

135-146: LGTM! The pending_issues annotation is well implemented.

The annotation correctly counts issues that are in backlog, unstarted, or started states while properly filtering out archived, draft, and deleted issues.

🧰 Tools
🪛 Ruff (0.8.2)

140-140: Line too long (97 > 88)

(E501)

@pushya22 pushya22 merged commit 369d927 into preview Jan 15, 2025
9 of 14 checks passed
@pushya22 pushya22 deleted the fix-transfer_issues_count branch January 15, 2025 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working 🌐frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants