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

[Enhancement] Add Timesheet status filter #8547

Merged
merged 3 commits into from
Nov 19, 2024

Conversation

samuelmbabhazi
Copy link
Contributor

@samuelmbabhazi samuelmbabhazi commented Nov 18, 2024

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

  • New Features

    • Enhanced filtering capabilities for timesheet queries, allowing users to filter by multiple statuses and associated task IDs.
    • New optional status property added to the timesheet query, enabling more granular control over retrieved data.
  • Bug Fixes

    • Improved query logic to ensure accurate filtering based on the new parameters.

@samuelmbabhazi samuelmbabhazi self-assigned this Nov 18, 2024
Copy link
Contributor

coderabbitai bot commented Nov 18, 2024

Walkthrough

The changes in this pull request involve updates to various interfaces and classes related to timesheet management. The IGetTimesheetInput and ITimeLogFilters interfaces have been modified to include new optional properties for filtering by status and task IDs. Additionally, the TimeSheetService class has been enhanced to support these new filtering capabilities in its query method. The TimesheetQueryDTO class has also been updated to include a status property for validation and API documentation purposes.

Changes

File Path Change Summary
packages/contracts/src/timesheet.model.ts Updated IGetTimesheetInput to add optional properties status?: TimesheetStatus[] and taskIds?: ID[]; updated ITimeLogFilters to add status?: TimesheetStatus[].
packages/core/src/time-tracking/timesheet/timesheet.service.ts Modified getFilterTimesheetQuery method to accept new parameters status and taskIds, and updated query logic to include filtering based on these properties.
packages/core/src/time-tracking/timesheet/dto/query/timesheet-query.dto.ts Added status: TimesheetStatus[] property to TimesheetQueryDTO, with validation decorators.

Possibly related PRs

  • Add issueType && taskStatus fields #8531: This PR adds new properties issueType and taskStatus to the ITask interface, which is relevant as it relates to task management and filtering, similar to the enhancements made in the main PR regarding timesheet filtering.
  • [Enhancement] Add All task Data #8537: This PR introduces additional properties startDate, resolvedAt, and version to the ITask interface, which also connects to the overall task management and filtering capabilities enhanced in the main PR.

Suggested reviewers

  • rahul-rocket

🐇 In the fields where timesheets grow,
New filters bloom, as we all know.
With status and tasks now in sight,
Queries dance, making data bright!
So hop along, let’s track the time,
With these changes, all will be fine! 🌼


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 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.

@samuelmbabhazi samuelmbabhazi marked this pull request as ready for review November 18, 2024 19:10
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
packages/core/src/shared/dto/selectors-query.dto.ts (1)

2-2: Remove unused import IsString

The IsString validator is imported but not used in this file.

-import { IsOptional, IsArray, IsString } from 'class-validator';
+import { IsOptional, IsArray } from 'class-validator';
packages/core/src/time-tracking/timesheet/timesheet.service.ts (2)

119-119: Consider adding status value validation.

The status filter accepts any values present in the array. Consider validating that the values match the TimesheetStatus enum to prevent invalid queries.

- ...(status.length > 0 ? { status: In(status) } : {}),
+ ...(status.length > 0 ? { 
+   status: In(
+     status.filter((s) => Object.values(TimesheetStatus).includes(s))
+   ) 
+ } : {}),

119-120: Consider adding database indexes for performance.

The new filtering conditions on status and taskIds columns might benefit from database indexes, especially if these filters are frequently used in queries.

Consider adding indexes in your database migration:

CREATE INDEX idx_timesheet_status ON "timesheet" ("status");
CREATE INDEX idx_timesheet_task ON "timesheet" ("taskIds");

Also applies to: 129-129

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1489cf2 and 9d55f58.

📒 Files selected for processing (3)
  • packages/contracts/src/timesheet.model.ts (2 hunks)
  • packages/core/src/shared/dto/selectors-query.dto.ts (2 hunks)
  • packages/core/src/time-tracking/timesheet/timesheet.service.ts (3 hunks)
🔇 Additional comments (5)
packages/core/src/shared/dto/selectors-query.dto.ts (1)

46-54: LGTM! Well-structured status filter implementation

The new status property is:

  • Properly typed as TimesheetStatus[]
  • Well-documented with JSDoc comments
  • Correctly decorated with necessary validators
  • Consistent with the existing filtering pattern
packages/core/src/time-tracking/timesheet/timesheet.service.ts (2)

87-95: LGTM! Clean parameter initialization.

The new parameters status and taskIds are properly initialized as empty arrays, following the existing pattern and preventing potential null/undefined issues.


119-120: Verify the taskIds column name in the database schema.

The condition taskIds: In(taskIds) might be using an incorrect column name. The typical pattern would be to use a relation or a specific column name like taskId.

Let's verify the entity structure:

packages/contracts/src/timesheet.model.ts (2)

92-93: LGTM! Well-structured filter properties added

The new optional properties status and taskIds are well-designed:

  • They follow the existing pattern of array-based filters
  • They maintain backward compatibility by being optional
  • The status property correctly uses the TimesheetStatus enum type

196-196: Verify the business logic for filtering time logs by timesheet status

While the implementation is technically correct, please verify if filtering time logs by timesheet status aligns with the business requirements. Time logs are typically filtered by their own properties rather than their parent timesheet's status.

Consider these questions:

  • Should time logs from a rejected timesheet be filtered out?
  • How should the status filter handle time logs that aren't associated with any timesheet?

Let's verify the relationship between time logs and timesheets:

Copy link

nx-cloud bot commented Nov 18, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 9622255. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


🟥 Failed Commands
nx build gauzy -c=production --prod --verbose

Sent with 💌 from NxCloud.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
packages/core/src/time-tracking/timesheet/dto/query/timesheet-query.dto.ts (1)

19-22: Consider enhancing enum validation.

While the current validation ensures the property is an array, it doesn't validate that the array elements are valid TimesheetStatus enum values.

Consider adding enum validation:

 @ApiPropertyOptional({ type: () => Array, isArray: true })
 @IsOptional()
 @IsArray()
+@IsEnum(TimesheetStatus, { each: true })
 status: TimesheetStatus[];
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2996d26 and 9622255.

📒 Files selected for processing (1)
  • packages/core/src/time-tracking/timesheet/dto/query/timesheet-query.dto.ts (1 hunks)
🔇 Additional comments (1)
packages/core/src/time-tracking/timesheet/dto/query/timesheet-query.dto.ts (1)

1-23: LGTM! Clean and well-structured implementation.

The implementation follows DTO best practices with proper typing, validation, and API documentation. The code is well-organized and maintains consistency with the existing codebase structure.

@rahul-rocket rahul-rocket merged commit 82a2e42 into develop Nov 19, 2024
12 of 19 checks passed
@rahul-rocket rahul-rocket deleted the feat/add-timesheet-status-filter branch November 19, 2024 07:20
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.

2 participants