|
| 1 | +# Description |
| 2 | +Fixes issue where the "Longest Open Issues" chart was limiting results to only 7 issues when multiple projects were selected, causing some issues to be hidden. Also fixes issue numbering consistency when multiple projects are selected. |
| 3 | + |
| 4 | +Fixes #4301 (Phase 2 Bugs - Priority Medium) |
| 5 | + |
| 6 | +## Related PRs (if any): |
| 7 | +Related to Frontend PR: #4653 |
| 8 | +To test this backend PR, you need to checkout the corresponding frontend PR branch. |
| 9 | + |
| 10 | +## Main changes explained: |
| 11 | +- **Updated `bmIssueController.js`** - `getLongestOpenIssues` function: |
| 12 | + - Removed `.slice(0, 7)` limit to return all issues from selected projects instead of just top 7 |
| 13 | + - Added `issueId` to response (MongoDB `_id` as string) for consistent issue identification |
| 14 | + - Added `projectId` to response to enable per-project issue numbering |
| 15 | + - Added `projectName` to response to distinguish issues across projects |
| 16 | + - Updated query to select `_id` field along with `issueTitle` and `issueDate` |
| 17 | + - Handle empty `issueTitle` arrays by returning `null` instead of `undefined` |
| 18 | + |
| 19 | +## How to test: |
| 20 | +1. Checkout branch `vamsidhar-fix/issue-chart-all-issues-visible` |
| 21 | +2. Run `npm run build` to compile the changes |
| 22 | +3. Restart the backend server |
| 23 | +4. Ensure the frontend is running with the corresponding frontend PR branch |
| 24 | +5. Navigate to BMDashboard → Issues → Longest Open Issues chart |
| 25 | +6. **Test Scenario 1: Select only "Building 3"** |
| 26 | + - Should show all Building 3 issues (e.g., "Paint Peeling in Conference Room", "Issue #1", "Issue #2", "Issue #3", "Issue #4") |
| 27 | + - Verify all issues are displayed, not limited to 7 |
| 28 | +7. **Test Scenario 2: Select "Building 3" and "Building 1" together** |
| 29 | + - Should show ALL issues from both projects (not limited to 7) |
| 30 | + - Should include all Building 3 issues (Issue #1, #2, #3, #4) AND all Building 1 issues |
| 31 | + - Verify no issues are missing compared to when selecting projects individually |
| 32 | + - Check backend console logs - should see: `[getLongestOpenIssues] Total issues found: X, Returning: X issues` where X is the total count (should be more than 7 for multiple projects) |
| 33 | +8. **Test Scenario 3: Select multiple projects with many issues** |
| 34 | + - Verify all issues are displayed, sorted by duration (longest first) |
| 35 | + - Check backend console logs to verify the count of issues being returned |
| 36 | + - Verify the response includes `issueId`, `projectId`, and `projectName` fields for each issue |
| 37 | + |
| 38 | +## Expected behavior: |
| 39 | +- When selecting multiple projects, ALL issues from all selected projects should be visible |
| 40 | +- Issues should be sorted by duration (longest open first) |
| 41 | +- No limit on the number of issues displayed |
| 42 | +- Each issue should have a unique `issueId` for consistent identification |
| 43 | +- Response should include `projectId` and `projectName` for frontend processing |
| 44 | + |
| 45 | +## Technical details: |
| 46 | +- The API endpoint `/bm/issues/longest-open` now returns all matching issues instead of limiting to 7 |
| 47 | +- Response includes `issueId`, `projectId`, and `projectName` fields for frontend processing |
| 48 | +- Issues with empty `issueTitle` arrays return `null` for `issueName` (frontend will generate names) |
| 49 | +- Debug logging added to verify issue counts in console |
| 50 | + |
| 51 | +## Note: |
| 52 | +This PR only includes backend changes. The frontend PR (#4653) will handle: |
| 53 | +- Using `issueId` for consistent issue numbering |
| 54 | +- Per-project issue numbering to avoid conflicts |
| 55 | +- Prefixing unnamed issues with project name when multiple projects are selected |
0 commit comments