Skip to content

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

Open
abhinav-TB wants to merge 2 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 2 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

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