Skip to content

Conversation

@vamsidharpanithi
Copy link
Contributor

@vamsidharpanithi vamsidharpanithi commented Jan 8, 2026

Description

This PR fixes the Time Log Visibility issue on the Member Group Check-In page by adding a new endpoint to fetch all project time logs and fixing the member lookup in the aggregation pipeline. Previously, the frontend could not fetch all time logs for a project, and member information was not being correctly joined, resulting in "Unknown User" being displayed.

Fixes # (bug list priority: Medium) - Time Log Visibility Issue on Member Group Check-In Page

Related PRs (if any):

This backend PR is related to the frontend PR #4685.
To test this backend PR you need to checkout the frontend PR #4685.

Main changes explained:

  • Update src/routes/bmdashboard/bmTimeLoggerRouter.js:
    • Added new GET endpoint /timelogger/:projectId/logs to fetch all time logs for a project
    • Reordered routes so the general route (/logs) comes before the member-specific route (/:memberId/logs) to prevent route matching conflicts that caused 404 errors
  • Update src/controllers/bmdashboard/bmTimeLoggerController.js:
    • Enhanced getProjectTimeLogs function to handle both all-logs and member-specific queries
    • Fixed member lookup in aggregation pipeline:
      • Added type conversion stage to safely convert member field to ObjectId (handles both string and ObjectId types)
      • Changed collection name from 'userprofiles' to 'userProfiles' to match the actual MongoDB collection name
      • Added proper ObjectId conversion for projectId and memberId in match stage
    • Added ObjectId conversion in startTimeLog to ensure proper MongoDB queries when creating new time logs
    • Added updatedAt field to the projection for proper sorting of completed logs

How to test:

  1. Checkout the Vamsidhar-fix/time-log-visibility-backend branch
  2. Run npm install to ensure dependencies are up to date
  3. Start the backend server: npm start
  4. Navigate to: http://localhost:5173/bmdashboard/timelog
  5. Select a project from the dropdown
  6. Verify the following:
    • Time Log Summary Table appears at the top showing completed time logs (if any exist)
    • Member names and roles are displayed correctly in the summary (not "Unknown User")
    • All project members are displayed in cards below the summary
    • Start timers for different members - they should all start from 00:00:00 (not from old values)
    • Pause a timer - it should show the exact time it was paused at (not jump to old value)
    • Resume a paused timer - it should continue from where it was paused (not jump to large old value)
    • Stop a timer - the final time should remain visible on the card (not reset to 00:00:00)
    • Summary table updates automatically after stopping a timer (within ~1 second) without page refresh
    • New completed log appears in the summary table with correct member info, times, and duration

Screenshots or videos of changes:

N/A (Backend API changes)
image

image image image

Copy link
Contributor

@sundarmachani sundarmachani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve reviewed this backend PR and tested the changes in coordination with the related frontend updates. Everything looks good and works as expected.
• Time log data is returned correctly and aligns with the frontend Time Log Summary component.
• Member details (names, roles, timestamps, durations) are accurate and consistent.
• No issues observed with timer state handling or completed time log records.
• Verified the behavior using before and after comparisons, and the fixes are clearly reflected.

The backend changes integrate well with the frontend and resolve the reported issues effectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants