Skip to content

Conversation

vaishalimaheshwari2000
Copy link

@vaishalimaheshwari2000 vaishalimaheshwari2000 commented Apr 29, 2025

Date: 30-04-2025

Developer Name: Vaishali


Issue Ticket Number

#2404

Description

This pull request updates the task status terminology from "COMPLETED" to "DONE" across the API responses and corresponding test cases. This change aligns with the updated terminology used across the system and improves clarity and consistency between backend logic, frontend usage, and developer understanding.

  • This PR is only for the API response , for DB next PR will be release later

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

ScreenShots

Screenshot 1

Screenshot 2025-04-30 003733

Screenshot 2

image

Screenshot 3

Screenshot 2025-04-30 001609

Screenshot 4

Screenshot 2025-04-30 014109

Test Coverage

Screenshot 1

Screenshot 2025-04-30 214019

Screenshot 2

Screenshot 2025-04-30 213939

Additional Notes

Copy link

coderabbitai bot commented Apr 29, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

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.

Summary by CodeRabbit

  • Refactor
    • Standardized task status values in API responses, ensuring all "COMPLETED" statuses are now returned as "DONE" across all task-related endpoints. This provides a more consistent experience when viewing task statuses.

Walkthrough

The changes standardize the task status value returned by several endpoints in the controllers/tasks.js file. Specifically, any task with a status of "COMPLETED" is now transformed to "DONE" before being sent in API responses. This transformation is applied within the fetchTasks, getUserTasks, getSelfTasks, and getTask functions. The underlying data and function signatures remain unchanged; only the outgoing response is affected to ensure consistent status naming.

Changes

File(s) Change Summary
controllers/tasks.js Updated response logic in fetchTasks, getUserTasks, getSelfTasks, and getTask to map status "COMPLETED" to "DONE" before returning tasks. No changes to function signatures or data storage.

Poem

In the meadow where tasks are spun,
"COMPLETED" transforms—its work is done.
Now "DONE" is the word that hops along,
In every response, it sings its song.
A tidy change, so neat and bright,
Task statuses now just feel right!
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

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

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

Copy link

@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 comments (1)
controllers/tasks.js (1)

395-395: 💡 Verification agent

🧩 Analysis chain

Consider updating COMPLETED references in status validation.

While these occurrences don't affect the API response transformation, for completeness and future-proofing, consider updating the status references in the validation logic as well.

- if (task.taskData.status === TASK_STATUS.DONE) {
+ if (task.taskData.status === TASK_STATUS.DONE) {
- if (task.taskData.status === TASK_STATUS.COMPLETED && req.body.percentCompleted < 100) {
+ if (task.taskData.status === TASK_STATUS.DONE && req.body.percentCompleted < 100) {

Let's verify if TASK_STATUS.COMPLETED and TASK_STATUS.DONE are defined in the constants:

Also applies to: 431-431


🏁 Script executed:

#!/bin/bash
# Check if TASK_STATUS.COMPLETED or TASK_STATUS.DONE are defined in the constants
rg -A 10 "TASK_STATUS\s*=" ../constants/tasks.js

Length of output: 112


🏁 Script executed:

#!/bin/bash
# Locate any files named tasks.js to find where TASK_STATUS might be defined
find . -type f -name "tasks.js"

# Search across the entire repo for TASK_STATUS definitions or usages
rg -n "TASK_STATUS" .

Length of output: 9787


Update legacy COMPLETED status references to DONE

To ensure you’re using the current TASK_STATUS values, replace all instances of TASK_STATUS.COMPLETED with TASK_STATUS.DONE in the validation logic in controllers/tasks.js. The check on line 395 is already using DONE and does not require changes.

• In controllers/tasks.js:

  • Line 431
    - if (task.taskData.status === TASK_STATUS.COMPLETED && req.body.percentCompleted < 100) {
    + if (task.taskData.status === TASK_STATUS.DONE      && req.body.percentCompleted < 100) {
  • Line 432
    -   if (status === TASK_STATUS.COMPLETED || !status) {
    +   if (status === TASK_STATUS.DONE      || !status) {
  • Line 437
    -   (status === TASK_STATUS.COMPLETED || status === TASK_STATUS.VERIFIED) &&
    +   (status === TASK_STATUS.DONE      || status === TASK_STATUS.VERIFIED) &&
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6a4319c and 887b557.

📒 Files selected for processing (1)
  • controllers/tasks.js (5 hunks)
🔇 Additional comments (5)
controllers/tasks.js (5)

200-208: Good implementation of the COMPLETED to DONE transformation.

This code correctly maps tasks with status "COMPLETED" to "DONE" in the fetchTasks response, aligning with the migration of task status terminology specified in the PR objectives.


212-212: LGTM - Response correctly uses transformed data.

The spread operator is properly used to include the transformed task data in the response.


245-250: Consistent transformation applied in getUserTasks.

The mapping logic correctly transforms tasks with status "COMPLETED" to "DONE" in the getUserTasks response, maintaining consistency with the fetchTasks implementation.


294-299: Consistent transformation applied in getSelfTasks.

The mapping logic correctly transforms tasks with status "COMPLETED" to "DONE" in the getSelfTasks response, maintaining consistency with other endpoints despite this being a deprecated function.


304-304: Response correctly uses transformed data.

The response now returns the statusChangedtasksData with the updated status values.

Comment on lines +318 to +320
if (taskData.status === "COMPLETED") {
taskData.status = "DONE";
}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Use consistent approach for task status transformation.

While this implementation works, it directly mutates the taskData object instead of creating a new object like in the other functions. This inconsistency in approach could make the code harder to maintain.

Consider using the same pattern as the other functions for consistency:

- if (taskData.status === "COMPLETED") {
-   taskData.status = "DONE";
- }
+ if (taskData.status === "COMPLETED") {
+   taskData = { ...taskData, status: "DONE" };
+ }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (taskData.status === "COMPLETED") {
taskData.status = "DONE";
}
if (taskData.status === "COMPLETED") {
taskData = { ...taskData, status: "DONE" };
}

@vaishalimaheshwari2000 vaishalimaheshwari2000 changed the title Chore:migrate task status Chore:Replace "COMPLETED" with "DONE" in Task Status in API and DB in backend Apr 30, 2025
@vaishalimaheshwari2000 vaishalimaheshwari2000 changed the title Chore:Replace "COMPLETED" with "DONE" in Task Status in API and DB in backend Chore:Replace "COMPLETED" with "DONE" in Task Status in API response in backend Apr 30, 2025
@vaishalimaheshwari2000 vaishalimaheshwari2000 changed the title Chore:Replace "COMPLETED" with "DONE" in Task Status in API response in backend Chore:Replace "COMPLETED" with "DONE" in Task Status in API response Apr 30, 2025
@vaishalimaheshwari2000 vaishalimaheshwari2000 changed the title Chore:Replace "COMPLETED" with "DONE" in Task Status in API response Chore: Update API response to replace task status "COMPLETED" with "DONE" Apr 30, 2025
const paginatedTasks = await fetchPaginatedTasks({ ...transformedQuery, prev, next, userFeatureFlag });

const updatedData = {
...paginatedTasks, // assuming your original JSON is stored in a variable called 'data'
Copy link
Member

Choose a reason for hiding this comment

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

remove this comment

Choose a reason for hiding this comment

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

Done , please check .

@JC-Coder
Copy link

@vaishalimaheshwari2000 why make a controller level update on a separate pr and proposing to create a separate pr for db level ?

Consider creating a transformer (for backword compatibility) , when returning any task , send it to the transformer firstly
that way you don't have to manually change completed to done everywhere

Note: From issue #2104

suggestion was said after wrapper "Once the DB has no more "COMPLETED" entries, remove the wrapper logic from step 1."

if you do write the script then you can still leave the transformer though, can be useful (you can add a note as to why it was added )

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.

3 participants