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-1887] chore: Optimistically update cycle and module distributions #5290

Merged
merged 1 commit into from
Aug 4, 2024

Conversation

rahulramesha
Copy link
Collaborator

@rahulramesha rahulramesha commented Aug 2, 2024

This PR updates the stats of cycles and modules optimistically with a front end logic without waiting for the server response.

Screen.Recording.2024-08-02.at.9.04.13.PM.mov

Summary by CodeRabbit

  • New Features

    • Improved tooltip rendering in the ProgressChart component for enhanced user experience.
    • New constants for categorizing completed and pending state groups for better clarity in application logic.
    • Added methods to facilitate local updates of cycle and module statistics, improving application performance.
    • Introduced a utility for managing distribution data to better track issue states within projects.
  • Bug Fixes

    • Enhanced handling of undefined values in tooltip rendering to prevent potential errors.
  • Chores

    • Added placeholder methods for future enhancements in various issue management classes.

Copy link
Contributor

coderabbitai bot commented Aug 2, 2024

Important

Review skipped

Auto reviews are limited to specific labels.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The recent changes enhance the application's state management and user interaction capabilities. Key updates include new methods for tracking and updating issue statistics across various contexts, improved tooltip rendering for better user experience, and the introduction of utility functions for managing distribution data. These modifications collectively aim to streamline functionality, bolster performance, and improve data integrity within the project management framework.

Changes

File Change Summary
web/core/components/core/sidebar/progress-chart.tsx Updated tooltip rendering to handle undefined values more robustly.
web/core/constants/state.ts Introduced COMPLETED_STATE_GROUPS and PENDING_STATE_GROUPS constants for better state categorization.
web/core/store/cycle.store.ts Added updateCycleDistribution method for local cycle statistics updates.
web/core/store/estimates/project-estimate.store.ts Added currentActiveEstimate property and computed getter for tracking active project estimates.
web/core/store/issue/archived/issue.store.ts Introduced updateParentStats method as a placeholder for future functionality.
web/core/store/issue/cycle/issue.store.ts Added updateParentStats for dynamic cycle statistics updates based on issue state changes.
web/core/store/issue/draft/issue.store.ts Added empty updateParentStats method for future enhancements.
web/core/store/issue/helpers/base-issues.store.ts Added abstract updateParentStats method and integrated it into various issue state modification methods for optimistic updates.
web/core/store/issue/module/issue.store.ts Introduced updateParentStats to manage parent statistics updates.
web/core/store/issue/profile/issue.store.ts Added updateParentStats as a placeholder for future implementation.
web/core/store/issue/project-views/issue.store.ts Implemented updateParentStats as an empty method for potential future enhancements.
web/core/store/issue/project/issue.store.ts Added updateParentStats as a placeholder for parent statistics functionality.
web/core/store/issue/workspace/issue.store.ts Introduced updateParentStats method for future enhancements.
web/core/store/module.store.ts Added updateModuleDistribution method for local updates to module statistics.
web/helpers/distribution-update.helper.ts Introduced utility functions and types for managing distribution data updates related to issues.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant Store
    participant Backend

    User->>App: Interacts with UI
    App->>Store: Request data update
    Store->>Store: Update local statistics
    Store-->>App: Return updated data
    App->>User: Display updated UI
Loading

Poem

🐰
In the fields where projects grow,
Stats and states begin to flow.
With updates swift and tooltips bright,
We hop along, all feels just right!
For every cycle, issue, and more,
New paths await, let’s explore!
🌼


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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: 1

Outside diff range, codebase verification and nitpick comments (2)
web/core/store/issue/project/issue.store.ts (1)

83-83: Add a TODO comment for future implementation.

The method updateParentStats is currently empty. Adding a TODO comment will help track the need for its implementation.

  updateParentStats = () => {};
+ // TODO: Implement the updateParentStats method
web/core/store/issue/profile/issue.store.ts (1)

95-95: Add a TODO comment for future implementation.

The method updateParentStats is currently empty. Adding a TODO comment will help track the need for its implementation.

  updateParentStats = () => {};
+ // TODO: Implement the updateParentStats method
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3a5c77e and 714064c.

Files selected for processing (15)
  • web/core/components/core/sidebar/progress-chart.tsx (1 hunks)
  • web/core/constants/state.ts (1 hunks)
  • web/core/store/cycle.store.ts (3 hunks)
  • web/core/store/estimates/project-estimate.store.ts (3 hunks)
  • web/core/store/issue/archived/issue.store.ts (1 hunks)
  • web/core/store/issue/cycle/issue.store.ts (2 hunks)
  • web/core/store/issue/draft/issue.store.ts (1 hunks)
  • web/core/store/issue/helpers/base-issues.store.ts (13 hunks)
  • web/core/store/issue/module/issue.store.ts (2 hunks)
  • web/core/store/issue/profile/issue.store.ts (1 hunks)
  • web/core/store/issue/project-views/issue.store.ts (1 hunks)
  • web/core/store/issue/project/issue.store.ts (1 hunks)
  • web/core/store/issue/workspace/issue.store.ts (1 hunks)
  • web/core/store/module.store.ts (3 hunks)
  • web/helpers/distribution-update.helper.ts (1 hunks)
Additional comments not posted (27)
web/core/constants/state.ts (2)

43-43: LGTM!

The COMPLETED_STATE_GROUPS constant is correctly defined and enhances the clarity of state groupings.


44-49: LGTM!

The PENDING_STATE_GROUPS constant is correctly defined and aggregates several state keys, enhancing the organization of state groupings.

web/core/components/core/sidebar/progress-chart.tsx (1)

139-139: LGTM!

The conditional access pattern for datum.slice.points enhances the robustness of the tooltip rendering by preventing potential runtime errors.

web/core/store/issue/project-views/issue.store.ts (2)

73-74: Implement functionality for updateParentStats.

The updateParentStats method is currently an empty placeholder. Ensure to implement the intended functionality or remove the method if it is not required.


73-73: Implement functionality for fetchParentStats.

The fetchParentStats method is currently an empty async function. Ensure to implement the intended functionality or remove the method if it is not required.

web/core/store/issue/draft/issue.store.ts (1)

74-75: Implement functionality for updateParentStats.

The updateParentStats method is currently an empty placeholder. Ensure to implement the intended functionality or remove the method if it is not required.

web/core/store/issue/archived/issue.store.ts (1)

77-78: Implement functionality for updateParentStats.

The updateParentStats method is currently an empty placeholder. Ensure to implement the intended functionality or remove the method if it is not required.

web/core/store/issue/module/issue.store.ts (1)

94-112: LGTM!

The method updateParentStats is correctly implemented and aligns with the class structure.

web/core/store/estimates/project-estimate.store.ts (2)

29-29: LGTM!

The addition of currentActiveEstimate as an optional property in the IProjectEstimateStore interface enhances state management by allowing direct tracking of the currently active estimate.


65-65: LGTM!

The computed property currentActiveEstimate in the ProjectEstimateStore class correctly retrieves the current active estimate based on the project's ID. This enhances the functionality by providing direct access to the active estimate related to a specific project.

Also applies to: 90-102

web/helpers/distribution-update.helper.ts (5)

71-102: LGTM!

The function getDistributionPathsPostUpdate correctly computes distribution updates by considering the previous and next issue states, as well as the current state map and project estimate. The logic for handling completed status and chart updates is sound.


112-153: LGTM!

The function getDistributionDataOfIssue correctly computes distribution data for a single issue state. It handles the case where the issue does not exist and computes path updates, assignee updates, label updates, and chart updates based on the issue state.


163-187: LGTM!

The function getObjectDistributionArray correctly computes distribution updates for assignees and labels by iterating over each ID and computing updates based on the issue state.


197-223: LGTM!

The function getChartUpdates correctly computes chart distribution updates based on the issue's completion state and estimate points. It handles the case where the completion date does not exist appropriately.


230-281: LGTM!

The function updateDistribution correctly updates the distribution of either cycle or module object by iterating over path updates, assignee updates, and label updates to apply changes to the distribution object.

web/core/store/issue/cycle/issue.store.ts (2)

22-22: LGTM!

The import statement correctly includes the new helper function getDistributionPathsPostUpdate.


144-155: LGTM!

The method updateParentStats correctly computes distribution updates based on the previous and next issue states and updates the cycle distribution if cycleId is defined. This enhances the dynamic handling of issue state changes.

web/core/store/module.store.ts (1)

324-338: LGTM! Ensure correct usage of updateDistribution.

The code changes are approved.

However, verify that the updateDistribution function is used correctly. Ensure it updates the module's statistics as expected.

Verification successful

LGTM! Ensure correct usage of updateDistribution.

The code changes are approved. The updateDistribution function is correctly used to update module statistics locally.

  • web/core/store/module.store.ts: Usage of updateDistribution is correct.
  • web/helpers/distribution-update.helper.ts: The function is defined to handle updates appropriately.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct usage of the `updateDistribution` function.

# Test: Search for the `updateDistribution` function usage. Expect: Correct usage in the context of updating module statistics.
rg --type python -A 5 $'updateDistribution'

Length of output: 73


Script:

#!/bin/bash
# Description: Verify the correct usage of the `updateDistribution` function in TypeScript files.

# Test: Search for the `updateDistribution` function usage. Expect: Correct usage in the context of updating module statistics.
rg --type typescript -A 5 'updateDistribution'

Length of output: 81


Script:

#!/bin/bash
# Description: Verify the correct usage of the `updateDistribution` function in TypeScript files.

# Test: Search for the `updateDistribution` function usage. Expect: Correct usage in the context of updating module statistics.
rg --type ts -A 5 'updateDistribution'

Length of output: 2331

web/core/store/cycle.store.ts (1)

490-504: LGTM! Ensure correct usage of updateDistribution.

The code changes are approved.

However, verify that the updateDistribution function is used correctly. Ensure it updates the cycle's statistics as expected.

Verification successful

LGTM! Ensure correct usage of updateDistribution.

The code changes are approved. The updateDistribution function is used correctly within the updateCycleDistribution method to update the cycle's statistics.

  • web/helpers/distribution-update.helper.ts: Definition of updateDistribution
  • web/core/store/cycle.store.ts: Usage of updateDistribution in updateCycleDistribution
  • web/core/store/module.store.ts: Similar usage of updateDistribution
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct usage of the `updateDistribution` function.

# Test: Search for the `updateDistribution` function usage. Expect: Correct usage in the context of updating cycle statistics.
rg --type python -A 5 $'updateDistribution'

Length of output: 73


Script:

#!/bin/bash
# Description: Verify the correct usage of the `updateDistribution` function.

# Test: Search for the `updateDistribution` function definition and usage in TypeScript files.
rg --type typescript -A 5 'updateDistribution'

Length of output: 81


Script:

#!/bin/bash
# Description: Verify the correct usage of the `updateDistribution` function.

# Test: Search for the `updateDistribution` function definition and usage in TypeScript files.
rg --type ts -A 5 'updateDistribution'

Length of output: 2331

web/core/store/issue/helpers/base-issues.store.ts (8)

894-898: LGTM! Verify the impact on removeIssueFromCycle behavior.

The change ensures that parent stats are updated optimistically when an issue is removed from a cycle. Verify the impact on the method's behavior.

Verification successful

LGTM! Verify the impact on removeIssueFromCycle behavior.

The change ensures that parent stats are updated optimistically when an issue is removed from a cycle. The search results confirm that removeIssueFromCycle is invoked in various places and the updated code ensures updateParentStats is called optimistically. This aligns with the intended behavior of the change.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the change on `removeIssueFromCycle` behavior.

# Test: Search for calls to `removeIssueFromCycle` and ensure `updateParentStats` is invoked correctly.
rg --type typescript -A 5 $'removeIssueFromCycle'

Length of output: 83


Script:

#!/bin/bash
# Description: Verify the impact of the change on `removeIssueFromCycle` behavior.

# Test: Search for calls to `removeIssueFromCycle` and ensure `updateParentStats` is invoked correctly.
rg --type-add 'ts:*.ts' -A 5 'removeIssueFromCycle'

Length of output: 11388


676-680: LGTM! Verify the impact on issueArchive behavior.

The change ensures that parent stats are updated optimistically when an issue is archived. Verify the impact on the method's behavior.

Verification successful

LGTM! Verify the impact on issueArchive behavior.

The change ensures that parent stats are updated optimistically when an issue is archived. The impact on the method's behavior has been verified, and no issues were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the change on `issueArchive` behavior.

# Test: Search for calls to `issueArchive` and ensure `updateParentStats` is invoked correctly.
rg --type typescript -A 5 $'issueArchive'

Length of output: 75


Script:

#!/bin/bash
# Description: Verify the impact of the change on `issueArchive` behavior.

# Test: Search for calls to `issueArchive` and ensure `updateParentStats` is invoked correctly.
rg 'issueArchive' --glob '*.ts' -A 5

Length of output: 7240


562-567: LGTM! Verify the impact on issueUpdate behavior.

The change ensures that parent stats are updated optimistically before making the API call. Verify the impact on the method's behavior.

Verification successful

LGTM! Verify the impact on issueUpdate behavior.

The change ensures that parent stats are updated optimistically before making the API call. The updateParentStats method is invoked correctly within the issueUpdate method.

  • web/core/store/issue/helpers/base-issues.store.ts: Lines around 562-567.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the change on `issueUpdate` behavior.

# Test: Search for calls to `issueUpdate` and ensure `updateParentStats` is invoked correctly.
rg --type typescript -A 5 $'issueUpdate'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify the impact of the change on `issueUpdate` behavior.

# Test: Search for calls to `issueUpdate` in TypeScript files and ensure `updateParentStats` is invoked correctly.
rg 'issueUpdate' --glob '*.ts' -A 10

Length of output: 20024


644-649: LGTM! Verify the impact on removeIssue behavior.

The change ensures that parent stats are updated optimistically when an issue is removed. Verify the impact on the method's behavior.

Verification successful

LGTM! Verify the impact on removeIssue behavior.

The change ensures that parent stats are updated optimistically when an issue is removed. The updateParentStats method is invoked correctly within the removeIssue method, confirming the intended behavior.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the change on `removeIssue` behavior.

# Test: Search for calls to `removeIssue` and ensure `updateParentStats` is invoked correctly.
rg --type typescript -A 5 $'removeIssue'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify the impact of the change on `removeIssue` behavior.

# Test: Search for calls to `removeIssue` and ensure `updateParentStats` is invoked correctly.
rg --type ts -A 5 $'removeIssue'

Length of output: 70776


Script:

#!/bin/bash
# Description: Verify the invocation of `updateParentStats` within the `removeIssue` method.

# Test: Search for the implementation of `updateParentStats` and check its usage within `removeIssue`.
rg --type ts -A 5 $'updateParentStats'

Length of output: 8056


1170-1176: LGTM! Verify the impact on changeModulesInIssue behavior.

The change ensures that parent stats are updated optimistically when modules are changed in an issue. Verify the impact on the method's behavior.

Verification successful

LGTM! The change ensures that parent stats are updated optimistically when modules are changed in an issue. The implementation of changeModulesInIssue correctly invokes updateParentStats, confirming the intended behavior.

  • changeModulesInIssue method implementation in web/core/store/issue/helpers/base-issues.store.ts correctly calls updateParentStats.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the change on `changeModulesInIssue` behavior.

# Test: Search for calls to `changeModulesInIssue` and ensure `updateParentStats` is invoked correctly.
rg --type typescript -A 5 $'changeModulesInIssue'

Length of output: 83


Script:

#!/bin/bash
# Description: Verify the impact of the change on `changeModulesInIssue` behavior.

# Test: Search for calls to `changeModulesInIssue` and ensure `updateParentStats` is invoked correctly.
rg 'changeModulesInIssue' --glob '*.ts' -A 5

Length of output: 6324


Script:

#!/bin/bash
# Description: Extract the implementation of `changeModulesInIssue` and check for calls to `updateParentStats`.

# Extract the implementation of `changeModulesInIssue` from `web/core/store/issue/helpers/base-issues.store.ts`
rg 'changeModulesInIssue' -A 50 web/core/store/issue/helpers/base-issues.store.ts

# Check for calls to `updateParentStats` in the same file
rg 'updateParentStats' web/core/store/issue/helpers/base-issues.store.ts

Length of output: 8015


528-528: LGTM! Verify the impact on createIssue behavior.

The change ensures that parent stats are updated when a new issue is created if shouldUpdateList is true. Verify the impact on the method's behavior.

Verification successful

LGTM! Verify the impact on createIssue behavior.

The change ensures that parent stats are updated when a new issue is created if shouldUpdateList is true. The verification confirms that fetchParentStats is correctly invoked within the createIssue method.

  • web/core/store/issue/helpers/base-issues.store.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the change on `createIssue` behavior.

# Test: Search for calls to `createIssue` and ensure `fetchParentStats` is invoked correctly.
rg --type typescript -A 5 $'createIssue'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify the impact of the change on `createIssue` behavior.

# Test: Search for calls to `createIssue` and ensure `fetchParentStats` is invoked correctly.
rg --type ts -A 5 $'createIssue'

Length of output: 49804


Script:

#!/bin/bash
# Description: Verify that `fetchParentStats` is invoked within the `createIssue` method in `base-issues.store.ts`.

# Test: Search for `fetchParentStats` within the `createIssue` method.
ast-grep --lang typescript --pattern $'class $_ {
  $$$
  async createIssue($_, $_, $_, $_, $_) {
    $$$
    shouldUpdateList && (await this.fetchParentStats($_, $_));
    $$$
  }
  $$$
}' -- web/core/store/issue/helpers/base-issues.store.ts

Length of output: 243


Script:

#!/bin/bash
# Description: Verify that `fetchParentStats` is invoked within the `base-issues.store.ts` file.

# Test: Search for `fetchParentStats` invocation.
rg 'fetchParentStats' web/core/store/issue/helpers/base-issues.store.ts -A 5

Length of output: 4514


Line range hint 930-948:
LGTM! Verify the impact on addCycleToIssue behavior.

The change ensures that parent stats are updated optimistically when a cycle is added to an issue. Verify the impact on the method's behavior.

Verification successful

Change Verified: Impact on addCycleToIssue behavior is as expected.

The updateParentStats method is correctly invoked within the addCycleToIssue method, ensuring that parent stats are updated optimistically. No issues were found with the implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the change on `addCycleToIssue` behavior.

# Test: Search for calls to `addCycleToIssue` and ensure `updateParentStats` is invoked correctly.
rg --type typescript -A 5 $'addCycleToIssue'

Length of output: 78


Script:

#!/bin/bash
# Description: Verify the impact of the change on `addCycleToIssue` behavior.

# Locate TypeScript files and search for calls to `addCycleToIssue` to ensure `updateParentStats` is invoked correctly.
fd -e ts -e tsx -x rg 'addCycleToIssue' {} -A 5

Length of output: 6462


Script:

#!/bin/bash
# Description: Verify the impact of the change on `addCycleToIssue` behavior by checking for `updateParentStats` calls.

# Locate TypeScript files and search for `updateParentStats` within those files.
fd -e ts -e tsx -x rg 'updateParentStats' {}

Length of output: 1098


260-261: Ensure implementation of updateParentStats in derived classes.

The new abstract method updateParentStats is essential for optimistically updating parent statistics. Ensure that all derived classes implement this method correctly.

@@ -76,6 +76,9 @@ export class WorkspaceIssues extends BaseIssuesStore implements IWorkspaceIssues

fetchParentStats = () => {};

/** */
updateParentStats = () => {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement the updateParentStats method.

The method updateParentStats is defined but lacks an implementation. This suggests a potential enhancement to the class's functionality.

Do you need help implementing the updateParentStats method or should I open a GitHub issue to track this task?

@SatishGandham SatishGandham merged commit 93e6c3b into preview Aug 4, 2024
13 of 14 checks passed
@SatishGandham SatishGandham deleted the chore-distribution-update branch August 4, 2024 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants