-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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-2114]: Chore: project cycle optimization #5430
Conversation
…/makeplane/plane into chore/project-cycle-optimization
…ne/plane into chore/project-cycle-optimization
…/makeplane/plane into chore/project-cycle-optimization
WalkthroughThe changes introduced multiple new API endpoints for cycle progress and analytics, streamlining data retrieval and management. A custom hook was created to simplify cycle detail fetching, while existing components were refactored to enhance state management and improve code clarity. Additionally, type definitions were refined for better type safety, and new methods were added to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CycleDetailPage
participant useCyclesDetails
participant CycleService
participant CycleStore
User->>CycleDetailPage: Request Cycle Details
CycleDetailPage->>useCyclesDetails: Fetch Cycle Data
useCyclesDetails->>CycleService: Call API for Cycle Data
CycleService-->>useCyclesDetails: Return Cycle Data
useCyclesDetails-->>CycleDetailPage: Provide Cycle Data
CycleDetailPage-->>User: Display Cycle Details
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 as PR comments)
Additionally, you can add 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
Outside diff range, codebase verification and nitpick comments (1)
web/core/components/cycles/active-cycle/productivity.tsx (1)
Line range hint
1-49
: Consider re-adding loading feedback.The removal of the
useState
hook andfetchCycleDetails
function simplifies the component but may impact user experience by not providing loading feedback during data fetching. Consider re-adding some form of loading feedback to enhance user experience.Tools
Biome
[error] 40-40: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with(lint/complexity/noUselessTernary)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (11)
- apiserver/plane/app/urls/cycle.py (2 hunks)
- apiserver/plane/app/views/init.py (1 hunks)
- apiserver/plane/app/views/cycle/base.py (11 hunks)
- web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/[cycleId]/page.tsx (3 hunks)
- web/core/components/cycles/active-cycle/cycle-stats.tsx (7 hunks)
- web/core/components/cycles/active-cycle/productivity.tsx (4 hunks)
- web/core/components/cycles/active-cycle/progress.tsx (2 hunks)
- web/core/components/cycles/active-cycle/root.tsx (4 hunks)
- web/core/components/cycles/active-cycle/use-cycles-details.ts (1 hunks)
- web/core/services/cycle.service.ts (3 hunks)
- web/core/store/cycle.store.ts (7 hunks)
Additional context used
Ruff
apiserver/plane/app/views/__init__.py
101-101:
.cycle.base.CycleAnalyticsEndpoint
imported but unused; consider removing, adding to__all__
, or using a redundant alias(F401)
102-102:
.cycle.base.CycleProgressEndpoint
imported but unused; consider removing, adding to__all__
, or using a redundant alias(F401)
Additional comments not posted (38)
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/[cycleId]/page.tsx (3)
9-9
: LGTM!The new import statement for
useCyclesDetails
is correct.The code changes are approved.
33-37
: LGTM!The custom hook
useCyclesDetails
is correctly invoked with the necessary parameters.The code changes are approved.
54-54
: LGTM!The conditional rendering logic is correctly implemented and improves the readability of the component.
The code changes are approved.
apiserver/plane/app/urls/cycle.py (3)
9-10
: LGTM!The new import statements for
CycleProgressEndpoint
andCycleAnalyticsEndpoint
are correct.The code changes are approved.
111-115
: LGTM!The new route for
CycleProgressEndpoint
is correctly defined.The code changes are approved.
116-120
: LGTM!The new route for
CycleAnalyticsEndpoint
is correctly defined.The code changes are approved.
web/core/components/cycles/active-cycle/root.tsx (4)
19-19
: LGTM!The new import statement for
useCyclesDetails
is correct.The code changes are approved.
31-34
: LGTM!The custom hook
useCyclesDetails
is correctly invoked with the necessary parameters.The code changes are approved.
37-37
: LGTM!The conditional rendering logic is correctly implemented and improves the readability of the component.
The code changes are approved.
Line range hint
68-85
: LGTM!The updated props for
ActiveCycleProgress
,ActiveCycleProductivity
, andActiveCycleStats
are correctly passed.The code changes are approved.
web/core/components/cycles/active-cycle/use-cycles-details.ts (8)
1-8
: Import statements look good.The imports are well-organized and necessary for the functionality of the hook.
10-14
: Interface definition is clear.The
IActiveCycleDetails
interface is well-defined and provides a clear structure for the expected props.
16-25
: Destructuring props and initializing hooks.The props are correctly destructured, and necessary hooks are initialized. Ensure that
useIssues
anduseCycle
hooks are correctly implemented and imported.
27-29
: Fetching cycle details using SWR.The
useSWR
hooks are used effectively to fetch cycle details. Ensure thatfetchActiveCycleProgress
,fetchActiveCycleAnalytics
, andfetchActiveCycleIssues
functions handle errors appropriately.Verify that the functions handle errors appropriately and return meaningful error messages.
31-56
: Fetching cycle details using SWR.The
useSWR
hooks are used effectively to fetch cycle details. Ensure thatfetchActiveCycleProgress
,fetchActiveCycleAnalytics
, andfetchActiveCycleIssues
functions handle errors appropriately.Verify that the functions handle errors appropriately and return meaningful error messages.
58-58
: Fetching cycle issue details.The
getActiveCycleByIdFromIssue
function is used to fetch cycle issue details. Ensure that this function is correctly implemented and handles errors appropriately.Verify that the function handles errors appropriately and returns meaningful error messages.
60-84
: Callback function for updating filters.The
handleFiltersUpdate
function is well-implemented and usesuseCallback
for optimization. Ensure thatupdateFilters
function is correctly implemented and handles errors appropriately.Verify that the
updateFilters
function handles errors appropriately and returns meaningful error messages.
85-92
: Returning hook values.The hook returns necessary values and functions, making it easy to use in components.
web/core/components/cycles/active-cycle/progress.tsx (9)
Line range hint
4-21
: Import statements and prop types look good.The imports are well-organized and necessary for the functionality of the component. The prop types are well-defined and provide a clear structure for the expected props.
26-29
: Destructuring props and initializing hooks.The props are correctly destructured, and necessary hooks are initialized. Ensure that
useProjectState
hook is correctly implemented and imported.
30-45
: Derived values and grouped issues.The derived values and grouped issues are correctly calculated. Ensure that
PROGRESS_STATE_GROUPS_DETAILS
is correctly defined and imported.
46-46
: Component rendering logic.The component rendering logic is well-implemented and uses
isEmpty
to handle empty cycle data. This ensures robustness and prevents runtime errors.
47-47
: Progress section rendering.The progress section is correctly rendered based on the cycle data. Ensure that
LinearProgressIndicator
is correctly implemented and imported.
48-48
: Grouped issues rendering.The grouped issues are correctly rendered based on the cycle data. Ensure that
groupedProjectStates
is correctly defined and imported.
49-49
: Cancelled issues rendering.The cancelled issues are correctly rendered based on the cycle data.
Line range hint
50-50
: Empty state rendering.The empty state is correctly rendered when there are no issues. Ensure that
EmptyState
andEmptyStateType
are correctly implemented and imported.
Line range hint
51-51
: Loader rendering.The loader is correctly rendered when the cycle data is empty. Ensure that
Loader
is correctly implemented and imported.apiserver/plane/app/views/__init__.py (1)
Line range hint
1-100
: Import statements look good.The imports are well-organized and necessary for the functionality of the file.
Tools
Ruff
98-98:
.cycle.base.CycleUserPropertiesEndpoint
imported but unused; consider removing, adding to__all__
, or using a redundant alias(F401)
99-99: Redefinition of unused
CycleViewSet
from line 94Remove definition:
CycleViewSet
(F811)
99-99:
.cycle.base.CycleViewSet
imported but unused; consider removing, adding to__all__
, or using a redundant alias(F401)
100-100: Redefinition of unused
TransferCycleIssueEndpoint
from line 97Remove definition:
TransferCycleIssueEndpoint
(F811)
100-100:
.cycle.base.TransferCycleIssueEndpoint
imported but unused; consider removing, adding to__all__
, or using a redundant alias(F401)
101-101:
.cycle.base.CycleAnalyticsEndpoint
imported but unused; consider removing, adding to__all__
, or using a redundant alias(F401)
102-102:
.cycle.base.CycleProgressEndpoint
imported but unused; consider removing, adding to__all__
, or using a redundant alias(F401)
105-105:
.cycle.issue.CycleIssueViewSet
imported but unused; consider removing, adding to__all__
, or using a redundant alias(F401)
web/core/services/cycle.service.ts (2)
Line range hint
24-28
: LGTM!The function is correctly implemented with proper error handling. The updated return type enhances type safety.
The code changes are approved.
Line range hint
38-42
: LGTM!The function is correctly implemented with proper error handling. The updated return type enhances type safety.
The code changes are approved.
web/core/components/cycles/active-cycle/cycle-stats.tsx (1)
Line range hint
4-302
: LGTM!The addition of the
cycleIssueDetails
prop enhances the component's functionality. The removal of theuseSWR
hook and streamlined logic improve performance. The adjusted conditional rendering improves robustness.The code changes are approved.
web/core/store/cycle.store.ts (3)
65-71
: LGTM!The new methods
fetchActiveCycleProgress
andfetchActiveCycleAnalytics
are correctly added to theICycleStore
interface.The code changes are approved.
110-110
: Verify the impact of changingplotType
to a standard observable.Changing
plotType
fromobservable.ref
toobservable
will affect how changes to this property are tracked and reacted to within the MobX state management framework. Ensure this change doesn't introduce any unintended side effects.
130-131
: LGTM!The new methods
fetchActiveCycleProgress
andfetchActiveCycleAnalytics
are correctly implemented in theCycleStore
class. They include logic to update thecycleMap
with fetched data, ensuring the state reflects the most current information regarding cycles.The code changes are approved.
Also applies to: 486-492, 501-514
apiserver/plane/app/views/cycle/base.py (4)
30-30
: Verify the impact of reducing complexity inget_queryset
.The reduction in complexity simplifies the logic and reduces potential performance overhead. Ensure that the removal of detailed estimates does not affect any critical functionality.
1008-1143
: LGTM!The new class
CycleProgressEndpoint
is correctly implemented and enhances the functionality by allowing users to access summarized estimate data directly related to a specific cycle.The code changes are approved.
1144-1362
: LGTM!The new class
CycleAnalyticsEndpoint
is correctly implemented and enhances the functionality by allowing users to retrieve analytics based on either points or issues.The code changes are approved.
412-418
: Verify the impact of new annotations inretrieve
method.The new annotations provide additional information about the issues associated with a cycle. Ensure that these changes do not introduce any performance overhead.
CycleAnalyticsEndpoint, | ||
CycleProgressEndpoint, |
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.
Unused imports.
The CycleAnalyticsEndpoint
and CycleProgressEndpoint
are imported but not used in the file. Consider removing them or adding them to __all__
.
Apply this diff to remove the unused imports:
- CycleAnalyticsEndpoint,
- CycleProgressEndpoint,
Alternatively, if these endpoints are intended to be used elsewhere, add them to __all__
:
+__all__ = [
+ ...
+ "CycleAnalyticsEndpoint",
+ "CycleProgressEndpoint",
+]
Tools
Ruff
101-101:
.cycle.base.CycleAnalyticsEndpoint
imported but unused; consider removing, adding to__all__
, or using a redundant alias(F401)
102-102:
.cycle.base.CycleProgressEndpoint
imported but unused; consider removing, adding to__all__
, or using a redundant alias(F401)
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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- web/core/store/cycle.store.ts (6 hunks)
Files skipped from review as they are similar to previous changes (1)
- web/core/store/cycle.store.ts
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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- web/core/components/cycles/active-cycle/root.tsx (4 hunks)
Additional comments not posted (8)
web/core/components/cycles/active-cycle/root.tsx (8)
18-18
: LGTM!The import of
ActiveCycleIssueDetails
is necessary for type definition.The code changes are approved.
19-19
: LGTM!The import of
useCyclesDetails
is necessary for the new state management logic.The code changes are approved.
29-29
: LGTM!The
useCycle
hook is correctly used to manage the current project active cycle and loader state.The code changes are approved.
31-34
: LGTM!The
useCyclesDetails
custom hook is correctly used to manage the cycle details.The code changes are approved.
37-40
: LGTM!The loader state is correctly checked to show a loader if the active cycle is loading.
The code changes are approved.
68-73
: LGTM!The
ActiveCycleProgress
component props are correctly updated to enhance integration with the overall state management.The code changes are approved.
85-85
: LGTM!The
ActiveCycleStats
component prop is correctly updated to enhance integration with the overall state management.The code changes are approved.
85-85
: LGTM!The type casting ensures type safety for the
cycleIssueDetails
prop.The code changes are approved.
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
Outside diff range, codebase verification and nitpick comments (6)
web/core/components/cycles/active-cycle/root.tsx (2)
16-17
: Remove unused importActiveCycleIssueDetails
.The
ActiveCycleIssueDetails
import is not used in this file and can be removed to clean up the code.-import { ActiveCycleIssueDetails } from "@/store/issue/cycle";
75-75
: Remove unnecessary type assertion forcycleIssueDetails
.The type assertion
as ActiveCycleIssueDetails
is unnecessary if the type is already correctly inferred. Remove it to clean up the code.- cycleIssueDetails={cycleIssueDetails as ActiveCycleIssueDetails} + cycleIssueDetails={cycleIssueDetails}web/core/components/cycles/active-cycle/progress.tsx (3)
25-25
: DestructureworkspaceSlug
andprojectId
props for consistency.Destructure
workspaceSlug
andprojectId
props along withhandleFiltersUpdate
andcycle
for consistency.- const { handleFiltersUpdate, cycle } = props; + const { handleFiltersUpdate, cycle, workspaceSlug, projectId } = props;
29-29
: Use optional chaining forcycle.total_issues
.Use optional chaining to safely access
cycle.total_issues
to prevent potential runtime errors.- value: cycle && cycle.total_issues > 0 ? (cycle[group.key as keyof ICycle] as number) : 0, + value: cycle?.total_issues > 0 ? (cycle[group.key as keyof ICycle] as number) : 0,
38-41
: Use optional chaining forcycle
properties.Use optional chaining to safely access
cycle
properties to prevent potential runtime errors.- completed: cycle?.completed_issues, - started: cycle?.started_issues, - unstarted: cycle?.unstarted_issues, - backlog: cycle?.backlog_issues, + completed: cycle?.completed_issues ?? 0, + started: cycle?.started_issues ?? 0, + unstarted: cycle?.unstarted_issues ?? 0, + backlog: cycle?.backlog_issues ?? 0,web/core/components/cycles/analytics-sidebar/issue-progress.tsx (1)
11-11
: Remove unused importSpinner
.The
Spinner
import is not used in this file and can be removed to clean up the code.- import { CustomSelect, Loader, Spinner } from "@plane/ui"; + import { CustomSelect, Loader } from "@plane/ui";
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- web/core/components/cycles/active-cycle/productivity.tsx (4 hunks)
- web/core/components/cycles/active-cycle/progress.tsx (1 hunks)
- web/core/components/cycles/active-cycle/root.tsx (4 hunks)
- web/core/components/cycles/active-cycle/use-cycles-details.ts (1 hunks)
- web/core/components/cycles/analytics-sidebar/issue-progress.tsx (3 hunks)
Files skipped from review as they are similar to previous changes (2)
- web/core/components/cycles/active-cycle/productivity.tsx
- web/core/components/cycles/active-cycle/use-cycles-details.ts
Additional context used
Biome
web/core/components/cycles/active-cycle/progress.tsx
[error] 45-45: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 45-45: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.(lint/suspicious/noPrototypeBuiltins)
Additional comments not posted (6)
web/core/components/cycles/active-cycle/root.tsx (3)
27-27
: Ensure proper error handling foruseCycle
hook.The
useCycle
hook is used to getcurrentProjectActiveCycle
andcurrentProjectActiveCycleId
. Ensure that the hook handles errors properly and returns default values if needed.Ensure that the
useCycle
hook handles errors and returns default values if needed.
29-32
: Ensure proper error handling foruseCyclesDetails
hook.The
useCyclesDetails
hook is used to gethandleFiltersUpdate
,activeCycle
, andcycleIssueDetails
. Ensure that the hook handles errors properly and returns default values if needed.Ensure that the
useCyclesDetails
hook handles errors and returns default values if needed.
58-63
: EnsureActiveCycleProgress
component handles null or undefinedcycle
prop.The
ActiveCycleProgress
component receivescycle
as a prop. Ensure that the component handles cases wherecycle
is null or undefined to prevent runtime errors.Ensure that the
ActiveCycleProgress
component handles null or undefinedcycle
prop.web/core/components/cycles/active-cycle/progress.tsx (2)
19-20
: EnsureworkspaceSlug
andprojectId
props are always provided.The component now accepts
workspaceSlug
andprojectId
as props. Ensure that these props are always provided to prevent runtime errors.Ensure that
workspaceSlug
andprojectId
props are always provided.
Line range hint
234-257
: EnsureLoader
component handles loading state properly.The
Loader
component is used as a fallback whencompletionChartDistributionData
is not available. Ensure that theLoader
component handles the loading state properly and provides a smooth user experience.Ensure that the
Loader
component handles the loading state properly.Tools
Biome
[error] 45-45: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 45-45: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.(lint/suspicious/noPrototypeBuiltins)
web/core/components/cycles/analytics-sidebar/issue-progress.tsx (1)
Line range hint
234-257
: EnsureLoader
component handles loading state properly.The
Loader
component is used as a fallback whencompletionChartDistributionData
is not available. Ensure that theLoader
component handles the loading state properly and provides a smooth user experience.Ensure that the
Loader
component handles the loading state properly.
} | ||
: {}; | ||
|
||
return cycle ? ( | ||
return cycle && cycle.hasOwnProperty("started_issues") ? ( |
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.
Use optional chaining and Object.hasOwn
for property check.
Replace hasOwnProperty
with Object.hasOwn
and use optional chaining for safer property access.
- return cycle && cycle.hasOwnProperty("started_issues") ? (
+ return cycle?.hasOwnProperty("started_issues") ? (
- return cycle && cycle.hasOwnProperty("started_issues") ? (
+ return cycle && Object.hasOwn(cycle, "started_issues") ? (
Tools
Biome
[error] 45-45: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 45-45: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.(lint/suspicious/noPrototypeBuiltins)
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.
Shouldn't this be in hooks?
Summary
Backend Change: Split the cycles api into /progress and /analytics
Frontend Change: Made integrational changes to incorporate the backend changes
[WEB-2114]
Summary by CodeRabbit
New Features
Improvements
Bug Fixes