Skip to content

Abhinav - feat(ki-inventory): add stats endpoint and DB seed script#2166

Open
abhinav-TB wants to merge 4 commits into
developmentfrom
feature/ki-inventory-api-connect
Open

Abhinav - feat(ki-inventory): add stats endpoint and DB seed script#2166
abhinav-TB wants to merge 4 commits into
developmentfrom
feature/ki-inventory-api-connect

Conversation

@abhinav-TB
Copy link
Copy Markdown
Member

@abhinav-TB abhinav-TB commented Apr 13, 2026

Description

image

Implements # Kitchen Inventory - API Connectivity


Related PRs (if any):

Frontend branch: feature/ki-inventory-api-connect
OneCommunityGlobal/HighestGoodNetworkApp#5142


Main changes explained:

  • Create src/scripts/seedKIInventoryItems.js — Script to seed the local MongoDB with sample inventory data (equipment, ingredients, seeds, etc.) and calculate expiration dates for testing preserved items logic.
  • Update src/controllers/kitchenandinventory/KIInventoryController.js — Added the getInventoryStats function to query the database and calculate total items, critical stock count, and low stock count based on current vs target thresholds.
  • Update src/routes/kitchenandinventory/KIInventoryRouter.js — Exposed the GET /inventory/items/stats route for the frontend to consume.

How to test:

  1. Check out branch feature/ki-inventory-api-connect in the HGNRest repository.
  2. Run npm install
  3. Run the seed script to populate your local database: node src/scripts/seedKIInventoryItems.js
  4. Run npm run dev to start the backend server.
  5. Hit GET http://localhost:4500/api/kitchenandinventory/inventory/items/stats in Postman.
  6. Verify the response is successful and returns an object detailing totalItems, criticalStock, and lowStock.

Screenshots or videos of changes:

image

Note:

@abhinav-TB abhinav-TB changed the title feat(ki-inventory): add stats endpoint and DB seed script Abhinav - feat(ki-inventory): add stats endpoint and DB seed script May 4, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 5, 2026

Copy link
Copy Markdown

@Radia731 Radia731 left a comment

Choose a reason for hiding this comment

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

Hello!

Checked out the feature/ki-inventory-api-connect branch, ran npm install, and successfully executed the seed script (node src/scripts/seedKIInventoryItems.js) to populate the local database.
Started the backend server with npm run dev and tested the new inventory endpoint via Postman. Here are the results (screenshots attached below):

GET (Inventory Stats): Hit the /api/kitchenandinventory/inventory/items/stats endpoint and verified it returned a successful response containing the expected object detailing totalItems, criticalStock, and lowStock. ✅

Summary - This PR is approved and ready for Jae to merge

Screenshot 2026-05-08 at 2 08 44 AM

Copy link
Copy Markdown

@DeepighaJ DeepighaJ left a comment

Choose a reason for hiding this comment

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

Hi,
Checked out the feature/ki-inventory-api-connect branch and ran npm install, executed the seed script. Started the backend server with npm run dev and tested the given end point . The response returned totalItems, criticalStock and lowStock as expected.

image

Copy link
Copy Markdown

@HemanthNidamanuru HemanthNidamanuru left a comment

Choose a reason for hiding this comment

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

Hi,

Thanks for the work on this! Tested locally, overall looks good.

One observation:

The seed script includes a preserved field but it is missing from the GET /api/kitchenandinventory/inventory/items/stats response. Please confirm if this is intentional or if it needs to be included in the stats endpoint.

Image Image

Copy link
Copy Markdown

@kunchalasireesha kunchalasireesha left a comment

Choose a reason for hiding this comment

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

Hi Abhinav, it looks like this PR currently has merge conflicts with the base branch. Could you please rebase or merge the latest changes from development into your branch and resolve the conflicts? Once the build passes, I’ll finish the review.

@abhinav-TB
Copy link
Copy Markdown
Member Author

abhinav-TB commented May 14, 2026

The seed script includes a preserved field but it is missing from the GET /api/kitchenandinventory/inventory/items/stats response.

Hi Hemanth,

Thanks for the catch. I've updated the getInventoryStats controller to calculate and include the preserved count so it now matches the seed script's summary output.

I've also merged the latest development branch into this feature branch

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@HemanthNidamanuru HemanthNidamanuru left a comment

Choose a reason for hiding this comment

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

Hi Abhinav,

the GET /api/kitchenandinventory/inventory/items/stats endpoint is not working in Postman and no response is being returned.

Image

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.

5 participants