-
-
Notifications
You must be signed in to change notification settings - Fork 44
Shreevaths taking over for Saicharan - Project status summary API for donut chart (backend) #1709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
one-community
merged 27 commits into
development
from
feature/project-status-donut-backend
Sep 1, 2026
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
7d8148d
feat: add project status summary API for donut chart (backend)
Saicharan1505 df94dbb
Merge branch development into current
Juhitha-Reddy 94fdea3
update lock file to sync dependencies
Juhitha-Reddy bc5a060
chore: resolved merge conflicts in app.js and package files
Saicharan1505 dfbbbba
chore: accepted latest messagingSocket.js from development during merge
Saicharan1505 a74c838
chore: rebuilt package-lock.json with cross-platform sharp binaries
Saicharan1505 f3d7616
chore: merge development into feature/project-status-donut-backend
vamsidharpanithi 5dea23b
fix(routes): import bmExpenditureRouter without invoking
vamsidharpanithi 550a4d9
chore(lockfile): resolve merge by taking development package-lock.json
vamsidharpanithi 8151be8
fix: update project status controller to use correct project model
Juhitha-Reddy e50392c
fix: update log of user controlled data
Juhitha-Reddy b868f11
Fixed coding standard issue
Juhitha-Reddy 2079780
Merge branch 'development' into feature/project-status-donut-backend
Juhitha-Reddy 9b4c76b
added try catch block
Juhitha-Reddy 58c22a9
Fixed lint issues
Juhitha-Reddy 74b8453
Resolve merge conflicts with origin/development
4cacc48
Resolve merge conflicts with origin/development
aa86136
Fix undefined isReceiverActive and isReceiverInChat variables
d28eb2c
fix: update projectStatusRouter to use correct controller with window…
saurabhdipte 6ad6ede
fix(merge): Merge branch 'development' of into feature/project-status…
shreevathsrao dcd2863
fix: Fix socket bug
shreevathsrao 1d0dfc4
fix: Merge branch 'development' into feature/project-status-donut-bac…
shreevathsrao 685d7c9
fix: Fix SonarCube issue
shreevathsrao 4942706
fix: Add Test cases
shreevathsrao ab7a1c3
fix: add more test cases
shreevathsrao 682a8ce
fix: merge branch 'development' of into feature/project-status-donut-…
shreevathsrao d6f06ca
fix: Merge branch 'development' of into feature/project-status-donut-…
shreevathsrao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| const dayjs = require('dayjs'); | ||
| const { getProjectStatusSummary } = require('../services/projectStatus.service'); | ||
|
|
||
| exports.fetchProjectStatus = async (req, res) => { | ||
| try { | ||
| const { startDate, endDate } = req.query; | ||
|
|
||
| // Validate dates | ||
| if (startDate && !dayjs(startDate, 'YYYY-MM-DD', true).isValid()) { | ||
| return res.status(400).json({ message: 'Invalid startDate (YYYY-MM-DD)' }); | ||
| } | ||
| if (endDate && !dayjs(endDate, 'YYYY-MM-DD', true).isValid()) { | ||
| return res.status(400).json({ message: 'Invalid endDate (YYYY-MM-DD)' }); | ||
| } | ||
| if (startDate && endDate && dayjs(startDate).isAfter(dayjs(endDate))) { | ||
| return res.status(400).json({ message: 'startDate cannot be after endDate' }); | ||
| } | ||
|
|
||
| const data = await getProjectStatusSummary({ startDate, endDate }); | ||
| return res.json(data); | ||
| } catch (err) { | ||
| // eslint-disable-next-line no-console | ||
| console.error('fetchProjectStatus error:', err); | ||
| return res.status(500).json({ message: 'Internal server error' }); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| const mongoose = require('mongoose'); | ||
|
|
||
| const { Schema } = mongoose; | ||
|
|
||
| const projectStatusSchema = new Schema( | ||
| { | ||
| name: { type: String, required: true }, | ||
| status: { | ||
| type: String, | ||
| enum: ['Active', 'Completed', 'Delayed'], | ||
| required: true, | ||
| }, | ||
| startDate: { type: Date, required: true }, | ||
| completionDate: { type: Date }, | ||
| }, | ||
| { timestamps: true }, | ||
| ); | ||
|
|
||
| // Indexes for faster queries | ||
| projectStatusSchema.index({ status: 1 }); | ||
| projectStatusSchema.index({ startDate: 1 }); | ||
|
|
||
| module.exports = mongoose.model('ProjectStatus', projectStatusSchema, 'projectStatus'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| const express = require('express'); | ||
|
|
||
| const router = express.Router(); | ||
| const { fetchProjectStatus } = require('../controllers/projectStatus.controller'); | ||
|
|
||
| // Quick sanity check endpoint | ||
| router.get('/status', (req, res) => { | ||
| console.log(' Project status route hit!'); | ||
| res.json({ message: ' projectStatus route is working!' }); | ||
| }); | ||
|
|
||
| // Main API endpoint | ||
| router.get('/summary', fetchProjectStatus); | ||
|
|
||
| // Export the router directly (not a function) | ||
| module.exports = router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| const dayjs = require('dayjs'); | ||
| const ProjectStatus = require('../models/projectStatus'); | ||
|
|
||
| // Utility to compute percentages safely | ||
| const calcPct = (count, total) => (total ? Number(((count / total) * 100).toFixed(1)) : 0.0); | ||
|
|
||
| async function getProjectStatusSummary({ startDate, endDate }) { | ||
| const match = {}; | ||
|
|
||
| if (startDate || endDate) { | ||
| match.startDate = {}; | ||
| if (startDate) match.startDate.$gte = dayjs(startDate).startOf('day').toDate(); | ||
| if (endDate) match.startDate.$lte = dayjs(endDate).endOf('day').toDate(); | ||
| } | ||
|
|
||
| const pipeline = [ | ||
| Object.keys(match).length ? { $match: match } : null, | ||
| { $group: { _id: '$status', count: { $sum: 1 } } }, | ||
| ].filter(Boolean); | ||
|
|
||
| const rows = await ProjectStatus.aggregate(pipeline); | ||
|
|
||
| // Normalize counts | ||
| const counts = { active: 0, completed: 0, delayed: 0 }; | ||
| rows.forEach((r) => { | ||
| if (r._id === 'Active') counts.active = r.count; | ||
| if (r._id === 'Completed') counts.completed = r.count; | ||
| if (r._id === 'Delayed') counts.delayed = r.count; | ||
| }); | ||
|
|
||
| const totalProjects = counts.active + counts.completed + counts.delayed; | ||
|
|
||
| return { | ||
| totalProjects, | ||
| activeProjects: counts.active, | ||
| completedProjects: counts.completed, | ||
| delayedProjects: counts.delayed, | ||
| percentages: { | ||
| active: calcPct(counts.active, totalProjects), | ||
| completed: calcPct(counts.completed, totalProjects), | ||
| delayed: calcPct(counts.delayed, totalProjects), | ||
| }, | ||
| window: { | ||
| startDate: startDate || null, | ||
| endDate: endDate || null, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| module.exports = { getProjectStatusSummary }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.