Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4b2b6e9
feat(ki-inventory): add stats endpoint and DB seed script
abhinav-TB Apr 13, 2026
da1621e
fix: added logic to return all events for community calendar
ChiragBellara May 5, 2026
67f5b77
fix(ki-inventory): resolve SonarQube exception handling and merge dev…
abhinav-TB May 5, 2026
13c1a82
Merge branch 'development' into feature/ki-inventory-api-connect
abhinav-TB May 14, 2026
8a78645
feat(inventory): add preserved items count to stats endpoint
abhinav-TB May 14, 2026
9c6e75e
Modilfied aggregation pipleline to fetch data properly
saisandeepkoritala May 15, 2026
ce97fbf
Changed build command to accomdate all pc user types
saisandeepkoritala May 15, 2026
b2d2487
Resolve merge conflicts with development branch
saisandeepkoritala May 15, 2026
03a24cb
fixed conflicts in yarn.lock
saisandeepkoritala May 17, 2026
accb234
Merge branch 'development' into chirag-fix-event-display-on-community…
ChiragBellara May 19, 2026
7b460bb
fix: add projectHistory tracking and getAllTimeprojectMembership endp…
sayali-2308 May 19, 2026
7c4fe59
chore(git): merge branch development and resolve conflicts
abhinav-TB May 23, 2026
a78a76e
test(kitchenandinventory): add KIInventoryController unit tests
abhinav-TB May 23, 2026
326c438
Merge pull request #2198 from OneCommunityGlobal/chirag-fix-event-dis…
one-community May 24, 2026
582873e
Merge pull request #2166 from OneCommunityGlobal/feature/ki-inventory…
one-community May 24, 2026
42fa6d0
resolved conflicts
saisandeepkoritala May 25, 2026
5b524ca
Merge pull request #2225 from OneCommunityGlobal/Sayali-Fix-AllTime-M…
one-community May 26, 2026
f64c88e
Merge pull request #2217 from OneCommunityGlobal/saisandeep-fix-task-…
one-community Jun 4, 2026
f86f812
fix(blueSq): Fixed Blue Square Bulk Issues
DiyaWadhwani Jun 5, 2026
62b0191
chore(test): fixed failing test
DiyaWadhwani Jun 5, 2026
e58e21e
chore(test): fixed failing test
DiyaWadhwani Jun 5, 2026
9692cc9
Merge pull request #2239 from OneCommunityGlobal/Diya_Fix_BlueSquareB…
one-community Jun 5, 2026
d14475d
fix(userProj): Fixed User Projects View
DiyaWadhwani Jun 6, 2026
c72854a
Merge pull request #2242 from OneCommunityGlobal/Diya_Fix_UserProject…
one-community Jun 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/controllers/activityController.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const Activity = require('../models/activity');
const LessonPlan = require('../models/lessonPlan');
const Subject = require('../models/subject');
const Atom = require('../models/atom');

const activityController = function () {
// Get all activities
const getActivities = async (req, res) => {
Expand Down
12 changes: 4 additions & 8 deletions src/controllers/eventController.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,10 @@ const autoPromoteFromWaitlist = (event) => {

while (event.currentAttendees < event.maxAttendees && event.waitlist.length > 0) {
const nextEntry = event.waitlist.shift();

if (!nextEntry?.userId) continue;
console.log(`Auto-promoting user from waitlist for event ${event._id}`);
event.currentAttendees += 1;
promotedUsers.push(nextEntry.userId);
if (nextEntry?.userId) {
event.currentAttendees += 1;
promotedUsers.push(nextEntry.userId);
}
}

return promotedUsers;
Expand Down Expand Up @@ -265,7 +264,6 @@ const joinWaitlist = async (req, res) => {
try {
const { eventId } = req.params;
const { userId } = req.body;
console.log('Join waitlist request received');

if (!userId || !mongoose.Types.ObjectId.isValid(userId)) {
return res.status(400).json({ error: 'Invalid userId' });
Expand Down Expand Up @@ -294,7 +292,6 @@ const joinWaitlist = async (req, res) => {
position,
});
} catch (error) {
console.error('JOIN WAITLIST ERROR:', error);
res.status(500).json({
error: 'Failed to join waitlist',
details: error.message,
Expand All @@ -304,7 +301,6 @@ const joinWaitlist = async (req, res) => {

const sendWaitlistNotification = async (user, event) => {
// TODO: Integrate with real notification service (email/queue)
console.log(`Sending waitlist notification for event ${event._id}`);
};

const leaveEvent = async (req, res) => {
Expand Down
37 changes: 37 additions & 0 deletions src/controllers/kitchenandinventory/KIInventoryController.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const KIInventoryController = () => {
const items = await KIInventoryItem.find(null, { __v: 0 }).lean().sort({ createdAt: -1 });
res.status(200).json({ message: 'All Items fetched successfully.', data: items });
} catch (err) {
console.error(err);
res.status(400).json({ message: 'Something went wrong while fetching items.' });
}
};
Expand All @@ -59,6 +60,7 @@ const KIInventoryController = () => {
.sort({ createdAt: -1 });
res.status(200).json({ message: 'Items fetched successfully.', data: items });
} catch (err) {
console.error(err);
res.status(400).json({ message: 'Something went wrong while fetching items.' });
}
};
Expand All @@ -74,6 +76,7 @@ const KIInventoryController = () => {
.sort({ presentQuantity: -1 });
res.status(200).json({ message: 'Preserved stock items fetched successfully.', data: items });
} catch (err) {
console.error(err);
res
.status(400)
.json({ message: 'Something went wrong while fetching preserved stock items.' });
Expand Down Expand Up @@ -154,6 +157,39 @@ const KIInventoryController = () => {
res.status(400).json({ message: err.message });
}
};
const getInventoryStats = async (req, res) => {
try {
// Only fetch the fields needed for stats — avoids sending full item payloads
const items = await KIInventoryItem.find(
{},
{ presentQuantity: 1, reorderAt: 1, category: 1, expiryDate: 1 },
).lean();
const totalItems = items.length;
const criticalStock = items.filter((i) => i.presentQuantity <= i.reorderAt * 0.5).length;
const lowStock = items.filter(
(i) => i.presentQuantity <= i.reorderAt && i.presentQuantity > i.reorderAt * 0.5,
).length;

const oneYearFromNow = new Date();
oneYearFromNow.setFullYear(oneYearFromNow.getFullYear() + 1);
const preserved = items.filter(
(i) => i.category === 'INGREDIENT' && new Date(i.expiryDate) >= oneYearFromNow,
).length;

res.status(200).json({
message: 'Inventory stats fetched successfully.',
data: {
totalItems,
criticalStock,
lowStock,
preserved,
},
});
} catch (err) {
console.error(err);
res.status(500).json({ message: 'Something went wrong while fetching inventory stats.' });
}
};
return {
addItem,
getItems,
Expand All @@ -162,6 +198,7 @@ const KIInventoryController = () => {
updateOnUsage,
updateStoredQuantity,
updateNextHarvest,
getInventoryStats,
};
};
module.exports = KIInventoryController;
Loading
Loading