Skip to content

Saurabh taking over for Saicharan - Project status summary API for donut chart (backend)#1709

Open
Saicharan1505 wants to merge 18 commits into
developmentfrom
feature/project-status-donut-backend
Open

Saurabh taking over for Saicharan - Project status summary API for donut chart (backend)#1709
Saicharan1505 wants to merge 18 commits into
developmentfrom
feature/project-status-donut-backend

Conversation

@Saicharan1505

@Saicharan1505 Saicharan1505 commented Sep 7, 2025

Copy link
Copy Markdown
Contributor

Description

Implements Phase 2 Summary Dashboard: Project Status Donut Chart (Backend).
This feature provides an API endpoint /api/project-status/summary that aggregates Active, Completed, and Delayed projects, supporting date filters.
Implements # (Phase 2 Action Item)

image image

Related PRS (if any):

This backend PR is related to the #4040 frontend PR.

Main changes explained:

  • Created new projectStatus model for storing project status data.
  • Implemented projectStatusService.js to aggregate counts and percentages.
  • Added projectStatusController.js to handle requests with optional date filters.
  • Created projectStatusRouter.js and registered it in routes.js.
  • API returns total projects, counts by status, percentages, and applied date window.
  • Tested endpoints in Postman for various date ranges.

How to test:

  1. Check out the current branch (or)
    Check into this branch:
    git fetch origin feature/project-status-donut-backend
    git checkout feature/project-status-donut-backend
  2. Run npm install and npm run dev.
  3. Use Postman to call:
    GET http://localhost:4500/api/project-status/summary
    • Without dates (returns all projects).
    • With ?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD filters.
  4. Verify API returns:
    • totalProjects
    • activeProjects, completedProjects, delayedProjects
    • percentages for each category
    • window with startDate and endDate.
  5. Confirm frontend donut chart reflects the API response.

Screenshots or videos of changes:

backend #1 backend #2 backend #3 backend #4 backend #5

Note:

  • Reviewers should verify aggregation logic in projectStatusService.js.
  • Double-check date filtering correctness.
  • Ensure API response matches frontend requirements.

@akshith312 akshith312 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested the PR locally. All the end points display the desired results.

project-status/summary:
image

With parameters:
image
image
image

@aditya2512 aditya2512 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The aggregation pipeline in projectStatus.service.js is well-designed efficiently grouping by project status and date range. The use of dayjs for robust date parsing and validation of both startDate and endDate parameters prevents edge case API misuse. Schema indexes on the project status fields are good for scale, especially with time windowed queries.
Error handling is granular, with informative responses for 400 (bad request) and 500 (internal error). Returning both count and percentage in the response is ideal for frontend integration, especially for chart generation (like a donut chart). Integration of the new route into the central router is clear and non-intrusive.
As a possible enhancement, adding API documentation (Swagger/OpenAPI or README) will further help frontend devs consume this endpoint. Recommend expanding test coverage with unit and integration tests for both controller and service logic to future proof any status logic changes.

@Prem203

Prem203 commented Sep 25, 2025

Copy link
Copy Markdown

Checked the PR with an admin account and all the endpoints are working as expected.

image image image image

@Saicharan1505 Saicharan1505 changed the title Project status summary API for donut chart (backend) Saicharan - Project status summary API for donut chart (backend) Oct 4, 2025

@Aswin20010 Aswin20010 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed PR #4040+1709 (Project Status Donut Chart Visualization). Verified proper integration with backend and correct rendering of the donut chart with Active, Completed, and Delayed project segments. Confirmed hover tooltips display accurate counts and percentages, and total project count appears at the chart center. Tested From/To date filters for functional accuracy and verified numeric data alignment in the right-side panel. Checked CSS module styling consistency and responsiveness. No functional or UI regressions found — approved the PR.

Screenshot 2025-10-22 at 1 13 43 PM Screenshot 2025-10-22 at 1 14 15 PM

@one-community one-community changed the title Saicharan - Project status summary API for donut chart (backend) Juhitha taking over for Saicharan - Project status summary API for donut chart (backend) Oct 31, 2025
@one-community one-community added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Dec 19, 2025

@Anusha-Gali Anusha-Gali left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi Juhitha,

I have reviewed your PR locally and the backend API calls work as per requirement.
Screenshot 2025-12-24 at 12 05 44 AM
Screenshot 2025-12-24 at 12 06 06 AM
Screenshot 2025-12-24 at 12 06 24 AM
Screenshot 2025-12-24 at 12 06 31 AM
Screenshot 2025-12-24 at 12 09 40 AM
Screenshot 2025-12-24 at 12 09 48 AM
Screenshot 2025-12-24 at 12 10 12 AM

@vamsidharpanithi vamsidharpanithi changed the title Juhitha taking over for Saicharan - Project status summary API for donut chart (backend) Vamsidhar taking over for Juhitha taking over for Saicharan - Project status summary API for donut chart (backend) Jan 10, 2026
@maithili20

Copy link
Copy Markdown
Contributor

@one-community one-community changed the title Vamsidhar taking over for Juhitha taking over for Saicharan - Project status summary API for donut chart (backend) Juhitha taking over for Saicharan - Project status summary API for donut chart (backend) Mar 1, 2026
@Juhitha-Reddy

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-03-02.at.10.32.27.PM.mov

Resolved merge conflicts and tested locally. Please verify

@sonarqubecloud

sonarqubecloud Bot commented Mar 3, 2026

Copy link
Copy Markdown

// Utility to compute percentages safely
const calcPct = (count, total) => (total ? Number(((count / total) * 100).toFixed(1)) : 0.0);

async function getProjectStatusSummary({ startDate, endDate }) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The function has no try/catch. If the aggregation fails, the error will propagate unhandled to the caller.

@SharadhaKasiviswanathan

Copy link
Copy Markdown
Contributor

I have tested and reviewed this PR locally, also posted comments and screenshots on the frontend for PR #4040
OneCommunityGlobal/HighestGoodNetworkApp#4040 (comment)

@sonarqubecloud

sonarqubecloud Bot commented Apr 6, 2026

Copy link
Copy Markdown

@one-community one-community changed the title Juhitha taking over for Saicharan - Project status summary API for donut chart (backend) Vamsidhar taking over for Saicharan - Project status summary API for donut chart (backend) Apr 26, 2026
@one-community one-community changed the title Vamsidhar taking over for Saicharan - Project status summary API for donut chart (backend) Juhitha taking over for Saicharan - Project status summary API for donut chart (backend) May 30, 2026
@one-community one-community changed the title Juhitha taking over for Saicharan - Project status summary API for donut chart (backend) Saurabh taking over for Saicharan - Project status summary API for donut chart (backend) Jun 15, 2026
@sonarqubecloud

Copy link
Copy Markdown

@handikaharianto handikaharianto left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi @Saicharan1505 , after reviewing your PR, I have concluded the following findings:

Requires some changes

Project summary data (without dates params) ❌

The response doesn't have the window property that includes startDate and endDate.
Image

Project summary data (with dates params)❌

The response doesn't have the window property that includes startDate and endDate.
Image

projectStatusService.js is not connected to projectStatusController.js

In the Note section that you wrote, you mentioned that we need to verify the aggregation logic in projectStatusService.js. However, you did not even use it and this file actually includes the window property that I mentioned earlier as missing.
Image

For the frontend side, I couldn't confirm the frontend donut chart reflects the API response because the frontend side has errors that are not fixed yet. refer to: this link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.