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

[Feature] Find Tasks with advanced filtering #8725

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

GloireMutaliko21
Copy link
Contributor

@GloireMutaliko21 GloireMutaliko21 commented Jan 10, 2025

PR

Please note: we will close your PR without comment if you do not check the boxes above and provide ALL requested information.


Summary by CodeRabbit

Release Notes: Task Advanced Filtering Enhancement

  • New Features

    • Introduced advanced task filtering capabilities.
    • Expanded task search and retrieval options with more granular filter parameters.
  • Improvements

    • Enhanced task management methods to support complex filtering.
    • Added support for filtering tasks by projects, teams, modules, sprints, members, tags, and more.
    • Improved query flexibility for task retrieval across different contexts.

Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

Walkthrough

This pull request introduces an advanced task filtering mechanism across multiple files in the task management system. The changes centralize task filtering options by creating a new ITaskAdvancedFilter interface and corresponding DTO. The modifications enhance the flexibility of task retrieval methods in the controller, service, and data transfer objects, allowing for more complex and granular task filtering across various dimensions such as projects, teams, modules, sprints, members, tags, and more.

Changes

File Change Summary
packages/contracts/src/lib/task.model.ts Added ITaskAdvancedFilter interface, updated IGetTasksByViewFilters, introduced IAdvancedTaskFiltering
packages/core/src/lib/tasks/dto/index.ts Added export for task-advanced-filter.dto
packages/core/src/lib/tasks/dto/task-advanced-filter.dto.ts Created new DTO TaskAdvancedFilterDTO with validated optional filtering properties
packages/core/src/lib/tasks/task.controller.ts Updated method signatures to include advanced filtering options
packages/core/src/lib/tasks/task.service.ts Added buildAdvancedWhereCondition method, updated task retrieval methods to support advanced filtering

Sequence Diagram

sequenceDiagram
    participant Client
    participant Controller
    participant Service
    participant Repository
    
    Client->>Controller: Request tasks with advanced filters
    Controller->>Service: Call task retrieval method with filters
    Service->>Service: Build advanced where condition
    Service->>Repository: Execute query with advanced filters
    Repository-->>Service: Return filtered tasks
    Service-->>Controller: Return paginated tasks
    Controller-->>Client: Respond with filtered tasks
Loading

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • rahul-rocket

Poem

🐰 Hopping through code with glee,
Advanced filters, now we see!
Tasks filtered with such grace,
A rabbit's coding embrace!
Complexity tamed, filters refined,
A development journey, brilliantly designed! 🚀


📜 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 a930c50 and 10b7a30.

📒 Files selected for processing (2)
  • packages/core/src/lib/tasks/dto/task-advanced-filter.dto.ts (1 hunks)
  • packages/core/src/lib/tasks/task.service.ts (15 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/core/src/lib/tasks/dto/task-advanced-filter.dto.ts
  • packages/core/src/lib/tasks/task.service.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: build

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.

@GloireMutaliko21 GloireMutaliko21 linked an issue Jan 10, 2025 that may be closed by this pull request
@GloireMutaliko21 GloireMutaliko21 changed the title Feat/find tasks with advanced filtering [Feature] Find Tasks with advanced filtering Jan 10, 2025
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: 3

🧹 Nitpick comments (4)
packages/contracts/src/lib/task.model.ts (2)

113-129: LGTM! Comprehensive and well-organized filtering interface.

The interface provides a flexible and extensive set of filtering options. Good use of optional properties and consistent typing with ID.

Consider adding JSDoc comments to document the purpose and usage of each filter property, especially for less obvious ones like dailyPlans.


131-133: Consider removing potentially redundant interface.

The IAdvancedTaskFiltering interface seems redundant as it only wraps an optional ITaskAdvancedFilter. Consider using ITaskAdvancedFilter directly since its properties are already optional.

-export interface IAdvancedTaskFiltering {
-  filters?: ITaskAdvancedFilter;
-}
packages/core/src/lib/tasks/task.controller.ts (1)

72-74: Update API documentation to reflect advanced filtering capabilities.

The method signatures have been consistently updated to support advanced filtering, but the @ApiOperation and @ApiResponse decorators need to be updated to document these new capabilities.

For each affected method, update the documentation to include information about the advanced filtering options. Example:

 @ApiOperation({ summary: 'Get tasks by pagination.' })
+@ApiOperation({
+  summary: 'Get tasks by pagination with advanced filtering options.',
+  description: 'Retrieves a paginated list of tasks with support for filtering by projects, teams, modules, sprints, members, tags, and more.'
+})

Also applies to: 122-124, 140-142, 158-160, 227-227, 244-246

packages/core/src/lib/tasks/dto/task-advanced-filter.dto.ts (1)

6-70: Enhance API documentation with property descriptions.

While the implementation is solid, consider adding descriptions to the @ApiPropertyOptional decorators to improve API documentation. This would help API consumers better understand the purpose of each filter.

Example enhancement:

-@ApiPropertyOptional({ type: Array })
+@ApiPropertyOptional({ 
+  type: Array,
+  description: 'Filter tasks by associated projects'
+})

Also consider grouping related properties (status/priority/size) together in the class definition for better maintainability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 943ba58 and a930c50.

📒 Files selected for processing (5)
  • packages/contracts/src/lib/task.model.ts (2 hunks)
  • packages/core/src/lib/tasks/dto/index.ts (1 hunks)
  • packages/core/src/lib/tasks/dto/task-advanced-filter.dto.ts (1 hunks)
  • packages/core/src/lib/tasks/task.controller.ts (7 hunks)
  • packages/core/src/lib/tasks/task.service.ts (15 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: test
  • GitHub Check: build
🔇 Additional comments (5)
packages/contracts/src/lib/task.model.ts (1)

92-99: LGTM! Well-structured interface extension.

The interface properly extends ITaskAdvancedFilter while maintaining specific view-related filters. Good separation of concerns between generic advanced filters and view-specific filters.

packages/core/src/lib/tasks/task.controller.ts (1)

26-33: LGTM! Well-organized imports.

Good use of destructuring and clear naming convention for DTOs.

packages/core/src/lib/tasks/dto/index.ts (1)

6-6: LGTM! Export follows established pattern.

The new export statement follows the existing barrel file pattern and correctly exposes the new DTO.

packages/core/src/lib/tasks/dto/task-advanced-filter.dto.ts (2)

1-5: LGTM! Clean implementation with proper imports and interface.

The class correctly implements the ITaskAdvancedFilter interface and imports all necessary decorators and types.


1-71: Verify the performance impact of multiple array filters.

The DTO allows for multiple array-based filters that could be combined. Ensure that the underlying query implementation can handle these combinations efficiently, especially when multiple filters are used simultaneously.

Let's check the service implementation:

✅ Verification successful

Multiple array filters implementation is performant

The current implementation efficiently handles multiple array filters by:

  • Using SQL IN clauses through TypeORM's In operator
  • Applying filters at the database level rather than in application memory
  • Conditionally including only non-empty filters to avoid unnecessary conditions

The implementation follows database best practices and doesn't require optimization.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the service method handling these filters
ast-grep --pattern 'async $method($_) {
  $$$
  where: {
    $$$
  }
  $$$
}'

Length of output: 79


Script:

#!/bin/bash
# Find task service files
fd "task.*service" packages/core/src

# Search for imports of TaskAdvancedFilterDTO
rg "TaskAdvancedFilterDTO" -A 5

# Search for query implementations with filters
rg "where.*\{" -A 10 packages/core/src/lib/tasks

Length of output: 39056


Script:

#!/bin/bash
# Search for index definitions in task entity
rg "@Index|@Entity" -A 5 packages/core/src/lib/tasks/task.entity.ts

# Look for any performance-related configurations
rg "typeorm.*config" -A 10 packages/core

Length of output: 1446

packages/core/src/lib/tasks/task.service.ts Outdated Show resolved Hide resolved
Copy link

nx-cloud bot commented Jan 10, 2025

View your CI Pipeline Execution ↗ for commit 10b7a30.

Command Status Duration Result
nx build gauzy -c=production --prod --verbose ✅ Succeeded 10m 5s View ↗
nx build desktop --base-href ./ ✅ Succeeded 1m 46s View ↗
nx build desktop-api --output-path=dist/apps/de... ✅ Succeeded 27s View ↗
nx run api:desktop-api ✅ Succeeded 1m 13s View ↗
nx run gauzy:desktop-ui --base-href ./ ✅ Succeeded 3m 55s View ↗
nx build api -c=production --prod ✅ Succeeded 1m 13s View ↗
nx build desktop-ui-lib --configuration=develop... ✅ Succeeded 31s View ↗
nx build desktop-ui-lib --configuration=production ✅ Succeeded 29s View ↗
Additional runs (53) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-01-10 17:38:27 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Retrieve Tasks with Advanced Filtering
1 participant