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-1989] chore: archived modules and cycles #5212

Merged

Conversation

NarayanBavisetti
Copy link
Collaborator

@NarayanBavisetti NarayanBavisetti commented Jul 23, 2024

Issue Link: WEB-1989

Summary by CodeRabbit

  • New Features

    • Enhanced cycle and module analytics with detailed estimate point calculations across various issue states.
    • Introduced separate functions for fetching details of archived cycles and modules, improving data retrieval based on status.
  • Bug Fixes

    • Adjusted querying methods for issues to utilize custom managers, potentially improving performance and filtering capabilities.
  • Refactor

    • Improved internal logic for handling estimate points and data responses in cycle and module views.
  • Documentation

    • Included updated API responses reflecting new fields for estimate points in cycle and module analytics.

Copy link
Contributor

coderabbitai bot commented Jul 23, 2024

Walkthrough

The changes across several files enhance the project's capability to manage cycle and module data more effectively. New methods and query structures have been introduced to improve how estimates are calculated and displayed for various states of issues. The integration of archived cycle and module details allows for more nuanced data handling, ensuring that both active and archived states are well represented in analytics and reporting.

Changes

File Path Change Summary
apiserver/plane/app/views/cycle/archive.py Enhanced get_queryset and get methods to include detailed estimates for issue states with new subqueries and annotations.
apiserver/plane/app/views/cycle/base.py Replaced Issue.objects.filter with Issue.issue_objects.filter, indicating a shift to a custom manager for better data handling.
apiserver/plane/app/views/module/archive.py Added queries for various estimate point states and adjusted response structure to enhance reporting capabilities.
apiserver/plane/app/views/module/base.py Similar shift to Issue.issue_objects.filter for improved data access in the retrieve method.
web/core/components/cycles/analytics-sidebar/issue-progress.tsx Introduced fetchArchivedCycleDetails function for better handling of active vs. archived cycle data.
web/core/components/modules/analytics-sidebar/issue-progress.tsx Added fetchArchivedModuleDetails to differentiate between active and archived modules in data retrieval.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CycleComponent
    participant ModuleComponent
    participant DataService
    
    User->>CycleComponent: Change cycle status
    CycleComponent->>DataService: fetchCycleDetails() or fetchArchivedCycleDetails()
    DataService-->>CycleComponent: Return cycle data
    CycleComponent-->>User: Update cycle view

    User->>ModuleComponent: Change module status
    ModuleComponent->>DataService: fetchModuleDetails() or fetchArchivedModuleDetails()
    DataService-->>ModuleComponent: Return module data
    ModuleComponent-->>User: Update module view
Loading

Poem

🐇 In fields of code where bunnies hop,
New features bloom, we won’t stop!
Estimates tallied, both old and new,
With archived tales that now come through.
Hopping with joy, we celebrate,
For data’s a dance, let’s elevate! 🎉


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.

@NarayanBavisetti NarayanBavisetti marked this pull request as ready for review July 30, 2024 10:58
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: 6

Outside diff range, codebase verification and nitpick comments (1)
web/core/components/modules/analytics-sidebar/issue-progress.tsx (1)

42-43: Ensure all instances of useModule match the new signature

The following files contain instances of useModule that do not match the updated signature including fetchArchivedModuleDetails:

  • space/core/components/issues/issue-layouts/properties/modules.tsx
  • web/core/layouts/auth-layout/project-wrapper.tsx
  • web/core/hooks/use-project-issue-properties.ts
  • web/core/hooks/use-workspace-issue-properties.ts
  • web/core/components/issues/issue-modal/modal.tsx
  • web/core/components/modules/module-card-item.tsx
  • web/core/components/modules/analytics-sidebar/issue-progress.tsx
  • web/core/components/modules/analytics-sidebar/root.tsx
  • web/core/components/issues/issue-layouts/kanban/swimlanes.tsx
  • web/core/components/issues/issue-layouts/kanban/default.tsx
  • web/core/components/issues/issue-layouts/list/default.tsx
  • web/core/components/issues/issue-layouts/filters/header/filters/module.tsx
  • web/core/components/issues/issue-layouts/filters/applied-filters/module.tsx
  • web/core/components/modules/module-list-item.tsx
  • web/core/components/modules/delete-module-modal.tsx
  • web/core/components/modules/quick-actions.tsx
  • web/core/components/modules/gantt-chart/modules-list-layout.tsx
  • web/core/components/modules/gantt-chart/blocks.tsx
  • web/core/components/modules/modal.tsx
  • web/core/components/modules/archived-modules/view.tsx
  • web/core/components/modules/archived-modules/modal.tsx
  • web/core/components/modules/archived-modules/root.tsx
  • web/core/components/modules/module-list-item-action.tsx
  • web/core/components/core/sidebar/links-list.tsx
  • web/core/components/dropdowns/module/module-options.tsx
  • web/core/components/dropdowns/module/index.tsx
  • web/core/components/analytics/custom-analytics/sidebar/sidebar-header.tsx
  • web/core/components/analytics/custom-analytics/sidebar/sidebar.tsx
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(list)/page.tsx
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(list)/mobile-header.tsx
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(detail)/header.tsx
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(detail)/mobile-header.tsx
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(detail)/[moduleId]/page.tsx

Please update these instances to ensure consistency across the codebase.

Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to useModule match the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `useModule` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type tsx -A 5 $'useModule'

Length of output: 58


Script:

#!/bin/bash
# Description: Verify all function calls to `useModule` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg 'useModule' -A 5

Length of output: 51905

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a8b2bcc and 319158d.

Files selected for processing (6)
  • apiserver/plane/app/views/cycle/archive.py (7 hunks)
  • apiserver/plane/app/views/cycle/base.py (8 hunks)
  • apiserver/plane/app/views/module/archive.py (14 hunks)
  • apiserver/plane/app/views/module/base.py (2 hunks)
  • web/core/components/cycles/analytics-sidebar/issue-progress.tsx (2 hunks)
  • web/core/components/modules/analytics-sidebar/issue-progress.tsx (2 hunks)
Additional comments not posted (11)
web/core/components/modules/analytics-sidebar/issue-progress.tsx (1)

104-108: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to fetchArchivedModuleDetails and fetchModuleDetails are correctly implemented.

Verification successful

Function usage verified

The function calls to fetchArchivedModuleDetails and fetchModuleDetails are correctly implemented across the codebase.

  • web/core/components/modules/module-peek-overview.tsx
  • web/core/components/modules/analytics-sidebar/issue-progress.tsx
  • web/core/components/issues/issue-modal/modal.tsx
  • web/core/components/analytics/custom-analytics/sidebar/sidebar.tsx
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/modules/(detail)/[moduleId]/page.tsx
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `fetchArchivedModuleDetails` and `fetchModuleDetails` are correctly implemented.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type tsx -A 5 $'fetchArchivedModuleDetails'
rg --type tsx -A 5 $'fetchModuleDetails'

Length of output: 143


Script:

#!/bin/bash
# Description: Verify all function calls to `fetchArchivedModuleDetails` and `fetchModuleDetails` are correctly implemented.

# Test: Search for the function usage in .tsx files. Expect: Only occurrences of the new signature.
rg --glob '*.tsx' -A 5 'fetchArchivedModuleDetails'
rg --glob '*.tsx' -A 5 'fetchModuleDetails'

Length of output: 9417

web/core/components/cycles/analytics-sidebar/issue-progress.tsx (2)

119-123: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to fetchArchivedCycleDetails and fetchCycleDetails are correctly implemented.

Verification successful

Function usage verified

The functions fetchArchivedCycleDetails and fetchCycleDetails are correctly implemented and used across the codebase.

  • web/core/store/cycle.store.ts
  • web/core/components/cycles/cycle-peek-overview.tsx
  • web/core/components/cycles/analytics-sidebar/issue-progress.tsx
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/[cycleId]/page.tsx
  • web/core/components/issues/issue-modal/modal.tsx
  • web/core/components/cycles/active-cycle/productivity.tsx
  • web/core/components/analytics/custom-analytics/sidebar/sidebar.tsx
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `fetchArchivedCycleDetails` and `fetchCycleDetails` are correctly implemented.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type tsx -A 5 $'fetchArchivedCycleDetails'
rg --type tsx -A 5 $'fetchCycleDetails'

Length of output: 141


Script:

#!/bin/bash
# Description: Verify all function calls to `fetchArchivedCycleDetails` and `fetchCycleDetails` are correctly implemented.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg -A 5 'fetchArchivedCycleDetails'
rg -A 5 'fetchCycleDetails'

Length of output: 14321


58-58: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to useCycle match the new signature.

apiserver/plane/app/views/module/archive.py (2)

Line range hint 357-441:
LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to get correctly handle the new calculations and response data structure.


106-189: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to get_queryset correctly handle the new queries.

apiserver/plane/app/views/cycle/archive.py (3)

364-367: Ensure new fields are correctly included in the response data.

The new fields completed_estimate_points and total_estimate_points should be correctly included in the response data. Verify that these fields are correctly populated.

Verification successful

The new fields completed_estimate_points and total_estimate_points are correctly included in the response data.

The search results confirm that these fields are present and being used in the codebase, including in the file apiserver/plane/app/views/cycle/archive.py.

  • File: apiserver/plane/app/views/cycle/archive.py
  • Lines: Multiple instances confirming the inclusion of completed_estimate_points and total_estimate_points.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that new fields are correctly included in the response data.

# Test: Search for new fields in the response data. Expect: Fields should be correctly populated.
rg --type python -A 2 $'completed_estimate_points'

Length of output: 80


Script:

#!/bin/bash
# Description: Verify that new fields are correctly included in the response data.

# Test: Search for new fields in the response data. Expect: Fields should be correctly populated.
rg 'completed_estimate_points' --glob '*.py' -A 2
rg 'total_estimate_points' --glob '*.py' -A 2

Length of output: 12122


255-290: Ensure all subqueries are correctly referenced in annotations.

The annotations for estimate points should correctly reference the subqueries defined earlier. Verify that all subqueries are correctly referenced and used.

Verification successful

All subqueries are correctly referenced in the annotations.

The subqueries backlog_estimate_point, unstarted_estimate_point, started_estimate_point, cancelled_estimate_point, completed_estimate_point, and total_estimate_point are correctly defined and used in the annotations.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all subqueries are correctly referenced in annotations.

# Test: Search for subquery references in annotations. Expect: All subqueries should be referenced.
rg --type python -A 2 $'Subquery'

Length of output: 63


Script:

#!/bin/bash
# Description: Verify that all subqueries are correctly referenced in annotations.

# Test: Search for subquery definitions and their references in Python files.

# Find all Python files and search for subquery definitions
fd -e py -x sh -c 'rg -A 2 "Subquery" {}'

# Find all Python files and search for the specific subqueries used in the annotations
fd -e py -x sh -c 'rg "backlog_estimate_point|unstarted_estimate_point|started_estimate_point|cancelled_estimate_point|completed_estimate_point|total_estimate_point" {}'

Length of output: 13921


391-470: Ensure estimate distribution is correctly calculated and included in the response data.

The estimate distribution for assignees and labels should be correctly calculated and included in the response data. Verify that the calculations are correct and the data is included.

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

Line range hint 557-607:
Ensure custom manager Issue.issue_objects is correctly used.

The custom manager Issue.issue_objects should be correctly used to query issues. Verify that the custom manager provides the expected functionality and performance.

Verification successful

Custom manager Issue.issue_objects is correctly used.

The custom manager Issue.issue_objects in the retrieve method correctly applies necessary filters to ensure only relevant issues are included in the queryset. The IssueManager class's get_queryset method provides the expected functionality and performance.

  • apiserver/plane/db/models/issue.py: Definition and implementation of IssueManager.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that custom manager `Issue.issue_objects` is correctly used.

# Test: Search for custom manager usage in the codebase. Expect: Custom manager should provide the expected functionality and performance.
rg --type python -A 5 $'Issue.issue_objects'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify that custom manager `Issue.issue_objects` is correctly used.

# Test: Search for custom manager usage in the codebase. Expect: Custom manager should provide the expected functionality and performance.
rg --type py -A 5 $'Issue.issue_objects'

Length of output: 83108


Script:

#!/bin/bash
# Description: Locate the definition and implementation of `Issue.issue_objects` in the `Issue` model.

# Test: Search for the `Issue` model definition and locate `issue_objects` within it.
rg --type py -A 10 $'class Issue' | rg 'issue_objects'

Length of output: 130


Script:

#!/bin/bash
# Description: Locate the definition and implementation of `Issue.issue_objects` in the `Issue` model.

# Test: Search for the `issue_objects` definition directly and include more context lines.
rg --type py -A 20 'issue_objects'

Length of output: 225942


Script:

#!/bin/bash
# Description: Locate and display the implementation of the `IssueManager` class.

# Test: Search for the `IssueManager` class definition and its implementation.
rg --type py -A 20 'class IssueManager'

Length of output: 1425

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

Line range hint 836-980:
Ensure custom manager Issue.issue_objects is correctly used.

The custom manager Issue.issue_objects should be correctly used to query issues. Verify that the custom manager provides the expected functionality and performance.

Verification successful

Custom manager Issue.issue_objects is correctly used.

The custom manager Issue.issue_objects is consistently used across multiple files and contexts in the codebase, indicating that it provides the expected functionality and performance.

  • Files with usage examples:
    • apiserver/plane/space/utils/grouper.py
    • apiserver/plane/space/views/inbox.py
    • apiserver/plane/space/views/issue.py
    • apiserver/plane/utils/analytics_plot.py
    • apiserver/plane/bgtasks/issue_automation_task.py
    • apiserver/plane/app/views/cycle/base.py
    • apiserver/plane/app/views/module/base.py
    • apiserver/plane/app/views/dashboard/base.py

The custom manager appears to be a well-integrated part of the codebase, used in a manner consistent with Django ORM practices.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that custom manager `Issue.issue_objects` is correctly used.

# Test: Search for custom manager usage in the codebase. Expect: Custom manager should provide the expected functionality and performance.
rg --type python -A 5 $'Issue.issue_objects'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify that custom manager `Issue.issue_objects` is correctly used.

# Test: Search for custom manager usage in the codebase. Expect: Custom manager should provide the expected functionality and performance.
rg --type py -A 5 $'Issue.issue_objects'

Length of output: 83108


Line range hint 387-467:
Ensure custom manager Issue.issue_objects is correctly used.

The custom manager Issue.issue_objects should be correctly used to query issues. Verify that the custom manager provides the expected functionality and performance.

Verification successful

Custom manager Issue.issue_objects is correctly used.

The custom manager Issue.issue_objects is consistently and correctly used across multiple files in the codebase for filtering, annotating, and aggregating data.

  • Files with usage:
    • apiserver/plane/utils/grouper.py
    • apiserver/plane/utils/analytics_plot.py
    • apiserver/plane/space/views/inbox.py
    • apiserver/plane/space/views/issue.py
    • apiserver/plane/app/views/cycle/archive.py
    • apiserver/plane/app/views/cycle/base.py
    • apiserver/plane/app/views/workspace/user.py
    • apiserver/plane/app/views/view/base.py
    • apiserver/plane/app/views/workspace/base.py
    • apiserver/plane/app/views/search/base.py
    • apiserver/plane/app/views/project/base.py
    • apiserver/plane/app/views/module/archive.py
    • apiserver/plane/app/views/issue/base.py
    • apiserver/plane/app/views/module/base.py
    • apiserver/plane/app/views/issue/relation.py
    • apiserver/plane/app/views/inbox/base.py
    • apiserver/plane/app/views/issue/draft.py
    • apiserver/plane/app/views/issue/sub_issue.py
    • apiserver/plane/app/views/analytic/base.py
    • apiserver/plane/bgtasks/issue_automation_task.py
    • apiserver/plane/app/views/module/issue.py
    • apiserver/plane/bgtasks/analytic_plot_export.py
    • apiserver/plane/app/views/dashboard/base.py
    • apiserver/plane/api/views/module.py
    • apiserver/plane/api/views/state.py
    • apiserver/plane/api/views/cycle.py
    • apiserver/plane/api/views/issue.py
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that custom manager `Issue.issue_objects` is correctly used.

# Test: Search for custom manager usage in the codebase. Expect: Custom manager should provide the expected functionality and performance.
rg --type python -A 5 $'Issue.issue_objects'

Length of output: 74


Script:

#!/bin/bash
# Description: Verify that custom manager `Issue.issue_objects` is correctly used.

# Test: Search for custom manager usage in the codebase. Expect: Custom manager should provide the expected functionality and performance.
rg --type py -A 5 'Issue.issue_objects'

Length of output: 83108

apiserver/plane/app/views/cycle/archive.py Show resolved Hide resolved
Comment on lines +63 to +76
unstarted_estimate_point = (
Issue.issue_objects.filter(
estimate_point__estimate__type="points",
state__group="unstarted",
issue_cycle__cycle_id=OuterRef("pk"),
)
.values("issue_cycle__cycle_id")
.annotate(
unstarted_estimate_point=Sum(
Cast("estimate_point__value", FloatField())
)
)
.values("unstarted_estimate_point")[:1]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance readability by extracting subquery logic into a helper function.

The subquery logic for calculating unstarted_estimate_point is repeated for other states. Extracting this logic into a helper function can improve readability and maintainability.

unstarted_estimate_point = get_estimate_point_subquery("unstarted")

Comment on lines +77 to +90
started_estimate_point = (
Issue.issue_objects.filter(
estimate_point__estimate__type="points",
state__group="started",
issue_cycle__cycle_id=OuterRef("pk"),
)
.values("issue_cycle__cycle_id")
.annotate(
started_estimate_point=Sum(
Cast("estimate_point__value", FloatField())
)
)
.values("started_estimate_point")[:1]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance readability by extracting subquery logic into a helper function.

The subquery logic for calculating started_estimate_point is repeated for other states. Extracting this logic into a helper function can improve readability and maintainability.

started_estimate_point = get_estimate_point_subquery("started")

Comment on lines +91 to +104
cancelled_estimate_point = (
Issue.issue_objects.filter(
estimate_point__estimate__type="points",
state__group="cancelled",
issue_cycle__cycle_id=OuterRef("pk"),
)
.values("issue_cycle__cycle_id")
.annotate(
cancelled_estimate_point=Sum(
Cast("estimate_point__value", FloatField())
)
)
.values("cancelled_estimate_point")[:1]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance readability by extracting subquery logic into a helper function.

The subquery logic for calculating cancelled_estimate_point is repeated for other states. Extracting this logic into a helper function can improve readability and maintainability.

cancelled_estimate_point = get_estimate_point_subquery("cancelled")

Comment on lines +105 to +118
completed_estimate_point = (
Issue.issue_objects.filter(
estimate_point__estimate__type="points",
state__group="completed",
issue_cycle__cycle_id=OuterRef("pk"),
)
.values("issue_cycle__cycle_id")
.annotate(
completed_estimate_points=Sum(
Cast("estimate_point__value", FloatField())
)
)
.values("completed_estimate_points")[:1]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance readability by extracting subquery logic into a helper function.

The subquery logic for calculating completed_estimate_point is repeated for other states. Extracting this logic into a helper function can improve readability and maintainability.

completed_estimate_point = get_estimate_point_subquery("completed")

Comment on lines +119 to +130
total_estimate_point = (
Issue.issue_objects.filter(
estimate_point__estimate__type="points",
issue_cycle__cycle_id=OuterRef("pk"),
)
.values("issue_cycle__cycle_id")
.annotate(
total_estimate_points=Sum(
Cast("estimate_point__value", FloatField())
)
)
.values("total_estimate_points")[:1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance readability by extracting subquery logic into a helper function.

The subquery logic for calculating total_estimate_point is repeated for other states. Extracting this logic into a helper function can improve readability and maintainability.

total_estimate_point = get_estimate_point_subquery(None)

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.

4 participants