Skip to content

Aayush create line chart showing total injuries over time backend#1687

Open
aayushshetty12 wants to merge 5 commits intodevelopmentfrom
aayush-create-line-chart-showing-total-injuries-over-time-backend
Open

Aayush create line chart showing total injuries over time backend#1687
aayushshetty12 wants to merge 5 commits intodevelopmentfrom
aayush-create-line-chart-showing-total-injuries-over-time-backend

Conversation

@aayushshetty12
Copy link
Copy Markdown
Contributor

@aayushshetty12 aayushshetty12 commented Aug 30, 2025

Description

Screenshot 2025-08-30 021327

Related PRS (if any):

To test this backend PR you need to checkout the #3995 frontend PR.

Main changes explained:

  • Added a controller file to get injuries over time for multiple projects returned in a json file.
  • Created a schema for injuries over time
  • Router for Injuries Over Time API

How to test:

  1. check into current branch
  2. do npm install and npm run start to run this PR locally
  3. follow instructions in frontend PR

Screenshots or videos of changes:

demo.mp4

Copy link
Copy Markdown
Contributor

@laharinandipati laharinandipati left a comment

Choose a reason for hiding this comment

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

Working as expected- didn't find any regressions in dark mode
Screenshot 2025-10-03 at 1 06 37 PM

@apoorvajainrp21
Copy link
Copy Markdown
Contributor

apoorvajainrp21 commented Oct 18, 2025

Tested functionality- commented in the corresponding #3995 chain.

@sanjeev29
Copy link
Copy Markdown

Tested the related frontend PR - 3995. The PR changes work as expected.

@tomkkl
Copy link
Copy Markdown

tomkkl commented Oct 24, 2025

Tested alongside Frontend PR 3995

@Sriamshreddy000
Copy link
Copy Markdown

Hey Aayush,
I tried setting up and testing this PR + Frontend PR #3995 locally.
While trying to start the backend, I encountered a build failure with the sharp package during npm install.
It seems to be a compatibility issue with ARM64 (Apple Silicon) devices.
Could you please guide me on resolving this or share if there’s an alternate setup for M1/M2 systems?

Attaching a screenshot of the output for reference.
Screenshot 2025-11-06 at 11 17 31 PM

@Vinay944924
Copy link
Copy Markdown

Hi Aayush,
Tested the PR locally and provided the screenshots in Frontend PR

Copy link
Copy Markdown

@Anusha-Gali Anusha-Gali left a comment

Choose a reason for hiding this comment

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

Hi Aayush,

I have reviewed this PR locally, similar to other i too am not able to see any projects and the screen says "No Data Available" as mentioned in my frontend.

Copy link
Copy Markdown
Contributor

@bhanuanishakkineni bhanuanishakkineni left a comment

Choose a reason for hiding this comment

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

Hello Aayush,
I have tried testing your PR. While I tried to start the server, it's unable to connect to database because of incorrect uri. Please update the uri in db.js as per new connection. Or use the uri from development branch.
image
I have updated this locally to test the PR and its working.
I have also commented on frontend PR #3995. Please check it out.

@SwathiAngadi
Copy link
Copy Markdown
Contributor

Hi Aayush,

Tried to review your PR. Similar to others I am also not able to see any projects and the page says "No Data Available".

Copy link
Copy Markdown

@Anusha-Gali Anusha-Gali left a comment

Choose a reason for hiding this comment

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

Hi Aayush,

I have re-reviewed your PR locally and it works as per requirement. Please update your DB.js file before merging into development.
Screenshot 2026-01-03 at 3 43 33 PM

@abhinav-TB
Copy link
Copy Markdown
Member

Hi Ayush , I have tested this PR and have given my comment here OneCommunityGlobal/HighestGoodNetworkApp#3995 (comment)

@Vikas-8055
Copy link
Copy Markdown

hi ayush , i have tested this PR and this is my comment
link:OneCommunityGlobal/HighestGoodNetworkApp#3995 (review)

Shravan-neelamsetty

This comment was marked as duplicate.

Copy link
Copy Markdown

@Shravan-neelamsetty Shravan-neelamsetty left a comment

Choose a reason for hiding this comment

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

hi ayush , i have tested this PR and this is my comment
link:OneCommunityGlobal/HighestGoodNetworkApp#3995 (review)

Copy link
Copy Markdown

@Ganesh112001 Ganesh112001 left a comment

Choose a reason for hiding this comment

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

Tested functionality- commented in the corresponding #3995 front end PR

@maithili20
Copy link
Copy Markdown
Contributor

@Sakshitapkir03
Copy link
Copy Markdown

Hello Ayush,
I have reviewed this PR with respect to the frontend PR # 3995 and left a comment on the same below : OneCommunityGlobal/HighestGoodNetworkApp#3995

const query = {};

if (projectIds) {
const projectIdArray = projectIds.split(',').map((id) => mongoose.Types.ObjectId(id));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If any of the projectIds values are not valid ObjectIds, the new mongoose.Types.ObjectId(id) call will throw an uncaught error.

const injuries = await InjuryOverTime.aggregate([
{ $match: query },
{
$group: {
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 $group stage groups by projectId, severity, injuryType, and department but not by date/month. Since the frontend charts injuries over time by month, this means the aggregation is collapsing all time periods into a single row per combination, which seems like it would break the chart entirely.

@SharadhaKasiviswanathan
Copy link
Copy Markdown

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

@sonarqubecloud
Copy link
Copy Markdown

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.