Skip to content

Commit cf68852

Browse files
Merge pull request #1982 from OneCommunityGlobal/vamsidhar-fix/issue-chart-all-issues-visible
Saurabh taking over Vamsidhar - fix: show all issues from selected projects without limit
2 parents dffd44c + 11b0200 commit cf68852

5 files changed

Lines changed: 32 additions & 14 deletions

File tree

src/controllers/activityController.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const Activity = require('../models/activity');
33
const LessonPlan = require('../models/lessonPlan');
44
const Subject = require('../models/subject');
55
const Atom = require('../models/atom');
6+
67
const activityController = function () {
78
// Get all activities
89
const getActivities = async (req, res) => {

src/controllers/bmdashboard/bmIssueController.js

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,18 +273,37 @@ const bmIssueController = function (BuildingIssue, injuryIssue) {
273273
query.projectId = { $in: filteredProjectIds };
274274
}
275275

276-
const issues = await BuildingIssue.find(query)
277-
.select('issueTitle issueDate projectId')
278-
.populate({
279-
path: 'projectId',
280-
select: 'projectName name',
281-
})
276+
let issues = await BuildingIssue.find(query)
277+
.select('issueTitle issueDate _id')
278+
.populate('projectId')
282279
.lean();
283280

284-
const grouped = buildGroupedIssues(issues);
285-
const response = buildLongestOpenResponse(grouped);
281+
issues = issues.map((issue) => {
282+
const durationInMonths = getDurationOpenMonths(issue.issueDate);
283+
return {
284+
issueName: issue.issueTitle && issue.issueTitle.length > 0 ? issue.issueTitle[0] : null,
285+
durationInMonths,
286+
issueId: issue._id.toString(),
287+
projectId: issue.projectId?._id?.toString() || issue.projectId?.toString(),
288+
projectName: issue.projectId?.name || null,
289+
};
290+
});
291+
292+
const sortedIssues = issues
293+
.sort((a, b) => b.durationInMonths - a.durationInMonths)
294+
.map(({ issueName, durationInMonths, issueId, projectId, projectName }) => ({
295+
issueName,
296+
durationOpen: durationInMonths,
297+
issueId,
298+
projectId,
299+
projectName,
300+
}));
301+
302+
console.log(
303+
`[getLongestOpenIssues] Total issues found: ${issues.length}, Returning: ${sortedIssues.length} issues`,
304+
);
286305

287-
res.json(response);
306+
res.json(sortedIssues);
288307
} catch (error) {
289308
res.status(500).json({ message: 'Error fetching longest open issues' });
290309
}

src/helpers/overviewReportHelper.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,6 @@ const overviewReportHelper = function () {
11011101
}
11021102

11031103
async function getTasksStats(startDate, endDate, comparisonStartDate, comparisonEndDate) {
1104-
11051104
if (comparisonStartDate && comparisonEndDate) {
11061105
const taskStats = await Task.aggregate([
11071106
{

src/routes/kitchenandinventory/KIInventoryRouter.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ const router = function () {
2222
};
2323

2424
module.exports = router;
25-

src/scripts/seedKIInventoryItems.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,12 @@ async function seed() {
470470

471471
// Quick stats summary
472472
const total = inserted.length;
473-
const critical = inserted.filter(i => i.presentQuantity <= i.reorderAt * 0.5).length;
473+
const critical = inserted.filter((i) => i.presentQuantity <= i.reorderAt * 0.5).length;
474474
const low = inserted.filter(
475-
i => i.presentQuantity <= i.reorderAt && i.presentQuantity > i.reorderAt * 0.5,
475+
(i) => i.presentQuantity <= i.reorderAt && i.presentQuantity > i.reorderAt * 0.5,
476476
).length;
477477
const preserved = inserted.filter(
478-
i =>
478+
(i) =>
479479
i.category === 'INGREDIENT' &&
480480
new Date(i.expiryDate) >= new Date(Date.now() + 365 * 24 * 60 * 60 * 1000),
481481
).length;

0 commit comments

Comments
 (0)