Skip to content

Amaresh - Phase 2 Summary Dashboard: Fix issue chart endpoints (BE) for PR #4608#2256

Open
amaresh2001 wants to merge 2 commits into
developmentfrom
amaresh/issue-charts-most-expensive-endpoint
Open

Amaresh - Phase 2 Summary Dashboard: Fix issue chart endpoints (BE) for PR #4608#2256
amaresh2001 wants to merge 2 commits into
developmentfrom
amaresh/issue-charts-most-expensive-endpoint

Conversation

@amaresh2001

@amaresh2001 amaresh2001 commented Jun 20, 2026

Copy link
Copy Markdown

Description

Implements Phase 2 Summary Dashboard - Horizontal Bar Graph of P5 (Backend)

Fixes the existing GET /api/bm/issues/longest-open endpoint to use correct query params (projectIds, startDate, endDate) and return { data: [...] } response format. Adds the missing
GET /api/bm/issues/most-expensive endpoint returning top 5 injury issues sorted by totalCost descending.

Related PRs (if any):

This backend PR is related to frontend PR #4608.
To fully test this backend PR, you need to checkout frontend PR #4608.

This PR is also a redo of: #1463

Main changes explained:

  • Update bmIssueController.js to fix getLongestOpenIssues params (dates/projects → projectIds/startDate/endDate) and response format (array → { data: [...] })
  • Update bmIssueController.js to add getMostExpensiveIssues function querying injuryIssue model, sorted by totalCost descending, top 5
  • Update bmIssueRouter.js to add GET /issues/most-expensive route

How to test:

  1. Checkout this branch (amaresh/issue-charts-most-expensive-endpoint)
  2. Run npm install and npm run dev to start the server
  3. Log in as admin and copy the Bearer token
  4. In Postman, add a header Key: Authorization, Value: your_token_here, and test:

GET http://localhost:4500/api/bm/issues/longest-open
GET http://localhost:4500/api/bm/issues/most-expensive
GET http://localhost:4500/api/bm/issues/longest-open?projectIds=654946c8bc5772e8caf7e963,654946b2bc5772e8caf7e962&startDate=2024-01-01&endDate=2026-12-31
GET http://localhost:4500/api/bm/issues/most-expensive?projectIds=68082bf5a6bd994e6c0c7375,6823e200a3475f85a80d5d9c&startDate=2024-01-01&endDate=2026-12-31

  1. Verify all return { "data": [...] } with top 5 results sorted correctly

Screenshots or videos of changes:

1. GET /issues/longest-open (no filters)

Screenshot 2026-06-20 at 12 45 56 PM

2. GET /issues/most-expensive (no filters)

Screenshot 2026-06-20 at 12 47 00 PM

3. GET /issues/longest-open with projectIds and date filters

Screenshot 2026-06-20 at 1 08 58 PM

4. GET /issues/most-expensive with projectIds and date filters

Screenshot 2026-06-20 at 1 09 51 PM

Note:

@kzou55 kzou55 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 Amaresh,

I ran and tested the current branch locally.

I was able to verify that the following endpoints work and that the data returned is in the correct format returned with the top 5 results sorted in the correct order.

  1. /api/bm/issues/longest-open
    Image

  2. api/bm/issues/most-expensive
    Image

  3. /api/bm/issues/longest-open with query parameters(projectId, startDate, endDate)
    Image

  4. api/bm/issues/most-expensive with query parameters(projectId, startDate, endDate)
    Image

@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

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

Tested the PR locally in postman. Data returns empty for the last most expensive Get request http://localhost:4500/api/bm/issues/most-expensive?projectIds=68082bf5a6bd994e6c0c7375,6823e200a3475f85a80d5d9c&startDate=2024-01-01&endDate=2026-12-31.
Future dates should be restricted in filters

Image Image Image Image

@kzou55 kzou55 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 Amaresh,

I ran and tested the PR alongside its associated frontend locally again.

Verfied

  • Get longest open

    Image
  • Get most expensive

    Image
  • Getting longest open with query parameters

    Image
  • Get most expensive with query parameters

    Image

@shree-vaths shree-vaths 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.

Hello, I reviewed #2256 on my local. This is working as expected.

Passing Cases
-The chart shows data in both dark and light mode.
-The chart loads for total data on both longest-open and expensive issues without date filter.
-The chart shows issues data with startDate, endDate and project filters data on both long-open and expensive issues.
-Upon clearing the filter, the chart shows total issues for all projects.
-The tooltip show useful data for good understanding.

Image Image Screenshot 2026-07-14 at 9 36 46 AM Screenshot 2026-07-14 at 9 37 10 AM

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.

5 participants