Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Dev#8

Merged
RandithaK merged 19 commits intomainfrom
dev
Nov 11, 2025
Merged

Dev#8
RandithaK merged 19 commits intomainfrom
dev

Conversation

@RandithaK
Copy link
Member

No description provided.

mehara-rothila and others added 18 commits November 7, 2025 00:41
- Update AssignEmployeesRequestDto to accept username instead of employee ID
- Add employee username validation in assignment flow
- Improve employee lookup by username in DataSeeder
- Update AppointmentController to handle username-based assignment
… ServiceTypeService for improved service type management
…integrating with Time Logging Service. Added TimeSession entity, repository, and response DTO. Updated AppointmentServiceImpl to handle clock in/out logic and notify customers. Enhanced TimeLoggingClient for JWT authentication. Created integration tests for time tracking features.
Copilot AI review requested due to automatic review settings November 11, 2025 18:28
@coderabbitai
Copy link

coderabbitai bot commented Nov 11, 2025

Warning

Rate limit exceeded

@RandithaK has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 51 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between eec3fcc and a93d36e.

📒 Files selected for processing (26)
  • .github/workflows/buildtest.yaml (1 hunks)
  • TIME_TRACKING_IMPLEMENTATION.md (1 hunks)
  • appointment-service/pom.xml (2 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/client/TimeLoggingClient.java (1 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/config/AppConfig.java (1 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/config/DataSeeder.java (8 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/config/WebClientConfig.java (1 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/controller/AppointmentController.java (2 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/controller/ServiceTypeController.java (3 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/dto/notification/NotificationRequest.java (1 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/dto/request/AssignEmployeesRequestDto.java (1 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/dto/response/AppointmentResponseDto.java (3 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/dto/response/TimeSessionResponse.java (1 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/entity/Appointment.java (3 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/entity/AppointmentStatus.java (1 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/entity/TimeSession.java (1 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/exception/InvalidStatusTransitionException.java (1 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/repository/AppointmentRepository.java (1 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/repository/TimeSessionRepository.java (1 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/service/AppointmentService.java (3 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/service/AppointmentStateTransitionValidator.java (1 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/service/NotificationClient.java (1 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/service/impl/AppointmentServiceImpl.java (15 hunks)
  • appointment-service/src/main/java/com/techtorque/appointment_service/service/impl/ServiceTypeServiceImpl.java (1 hunks)
  • appointment-service/src/main/resources/application.properties (1 hunks)
  • test-time-tracking.sh (1 hunks)
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements an intelligent time tracking system that integrates with the Time Logging Service, adds multi-employee assignment capability, and refactors service type management to use the Admin Service instead of local persistence.

Key changes:

  • Automated clock in/out functionality with live timer support for employee time tracking
  • Multi-employee assignment support for appointments (changed from single to multiple employees)
  • Service type management delegated to Admin Service via WebClient integration

Reviewed Changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
test-time-tracking.sh Integration test script for time tracking workflow
application.properties Added Admin Service URL configuration
ServiceTypeServiceImpl.java Refactored to fetch service types from Admin Service instead of local DB
AppointmentServiceImpl.java Added time tracking methods, multi-employee support, and enhanced notifications
NotificationClient.java New client for sending notifications to Notification Service
AppointmentStateTransitionValidator.java New component for validating appointment status transitions
AppointmentService.java Added interface methods for time tracking and employee assignment
TimeSessionRepository.java New repository for time session tracking
AppointmentRepository.java Updated query to support multi-employee assignments
InvalidStatusTransitionException.java Added constructor with custom reason message
TimeSession.java New entity for tracking clock in/out sessions
AppointmentStatus.java Added CUSTOMER_CONFIRMED status with documentation
Appointment.java Changed to multi-employee support and added vehicle arrival tracking
TimeSessionResponse.java New DTO for time session API responses
AppointmentResponseDto.java Updated to support multi-employee IDs and vehicle tracking
AssignEmployeesRequestDto.java New DTO for employee assignment requests
NotificationRequest.java New DTO for notification service requests
ServiceTypeController.java Updated authorization to allow customers access
AppointmentController.java Added endpoints for time tracking and employee workflows
WebClientConfig.java New configuration for Admin Service WebClient with JWT propagation
AppConfig.java Added RestTemplate bean configuration
DataSeeder.java Updated seed data to use multi-employee sets
TimeLoggingClient.java New client for Time Logging Service integration
pom.xml Added OAuth2 resource server and WebFlux dependencies
TIME_TRACKING_IMPLEMENTATION.md Comprehensive documentation for time tracking feature
buildtest.yaml Updated workflow triggers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


try {
// Call Admin Service public endpoint to get active service types
// Note: We ignore includeInactive parameter because public endpoint only returns active types
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

The includeInactive parameter is accepted but ignored, which creates an inconsistent API. Either remove the parameter from the method signature or implement proper handling by calling a different Admin Service endpoint that supports filtering inactive types.

Copilot uses AI. Check for mistakes.
com.techtorque.appointment_service.service.NotificationClient notificationClient,
com.techtorque.appointment_service.client.TimeLoggingClient timeLoggingClient,
AppointmentStateTransitionValidator stateTransitionValidator) {
this.appointmentRepository = appointmentRepository; // assign required repository
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

[nitpick] Unnecessary inline comment. The assignment is self-explanatory and the comment adds no value.

Suggested change
this.appointmentRepository = appointmentRepository; // assign required repository
this.appointmentRepository = appointmentRepository;

Copilot uses AI. Check for mistakes.
if ((newStatus == AppointmentStatus.CONFIRMED || newStatus == AppointmentStatus.IN_PROGRESS) &&
appointment.getAssignedEmployeeId() == null) {
appointment.setAssignedEmployeeId(employeeId);
(appointment.getAssignedEmployeeIds() == null || appointment.getAssignedEmployeeIds().isEmpty())) {
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

Potential NullPointerException. Line 269 checks if assignedEmployeeIds is null, but line 270 directly calls add() on it. If the collection is null, this will throw a NullPointerException. Initialize the set before adding: if (appointment.getAssignedEmployeeIds() == null) { appointment.setAssignedEmployeeIds(new HashSet<>()); } appointment.getAssignedEmployeeIds().add(employeeId);

Suggested change
(appointment.getAssignedEmployeeIds() == null || appointment.getAssignedEmployeeIds().isEmpty())) {
(appointment.getAssignedEmployeeIds() == null || appointment.getAssignedEmployeeIds().isEmpty())) {
if (appointment.getAssignedEmployeeIds() == null) {
appointment.setAssignedEmployeeIds(new HashSet<>());
}

Copilot uses AI. Check for mistakes.
.serviceType("AC Service")
.requestedDateTime(today.plusDays(1).atTime(10, 0))
.status(AppointmentStatus.CONFIRMED)
.specialInstructions("AC not cooling properly") // <-- Modified comment
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

Remove the inline comment '// <-- Modified comment' which appears to be a development note accidentally left in the code.

Suggested change
.specialInstructions("AC not cooling properly") // <-- Modified comment
.specialInstructions("AC not cooling properly")

Copilot uses AI. Check for mistakes.
.build());
.customerId(CUSTOMER_1_ID)
.vehicleId(VEHICLE_1_ID)
.assignedEmployeeIds(Set.of(EMPLOYEE_ID)) // <-- CHANGED
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

Remove the inline comment '// <-- CHANGED' which appears to be a development note accidentally left in the code.

Copilot uses AI. Check for mistakes.
// Tomorrow's appointment - CONFIRMED
.customerId(CUSTOMER_2_ID)
.vehicleId(VEHICLE_4_ID)
.assignedEmployeeIds(Set.of(EMPLOYEE_ID)) // <-- CHANGED
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

Remove the inline comment '// <-- CHANGED' which appears to be a development note accidentally left in the code.

Copilot uses AI. Check for mistakes.
.build());
.customerId(CUSTOMER_1_ID)
.vehicleId(VEHICLE_1_ID)
.assignedEmployeeIds(Set.of(EMPLOYEE_ID)) // <-- CHANGED (This was the line that failed)
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

Remove the inline comment '// <-- CHANGED (This was the line that failed)' which appears to be a development note accidentally left in the code.

Suggested change
.assignedEmployeeIds(Set.of(EMPLOYEE_ID)) // <-- CHANGED (This was the line that failed)
.assignedEmployeeIds(Set.of(EMPLOYEE_ID))

Copilot uses AI. Check for mistakes.
Appointment savedAppointment = appointmentRepository.save(appointment);

// Use the new Clock In functionality to start time tracking
clockIn(appointmentId, employeeId);
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

The acceptVehicleArrival method calls clockIn on line 749, but then returns the result of convertToDto(savedAppointment) on line 763 where savedAppointment was saved before the clockIn call. This means the returned appointment status will still be CONFIRMED instead of IN_PROGRESS (which is set by clockIn). Consider reloading the appointment after clockIn to return the updated status.

Copilot uses AI. Check for mistakes.
request.put("date", LocalDate.now().toString());
request.put("hours", hours);
request.put("description", description);
request.put("workType", "APPOINTMENT");
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

[nitpick] The workType value is hardcoded as 'APPOINTMENT', but the parameter name in the method is description. Consider adding workType as a parameter to make the method more flexible, or document why it's always 'APPOINTMENT' for this use case.

Copilot uses AI. Check for mistakes.
@CollectionTable(name = "appointment_assigned_employees", joinColumns = @JoinColumn(name = "appointment_id"))
@Column(name = "employee_id")
@Builder.Default
private Set<String> assignedEmployeeIds = new HashSet<>(); // Multiple employees can be assigned
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

getAssignedEmployeeIds exposes the internal representation stored in field assignedEmployeeIds. The value may be modified after this call to getAssignedEmployeeIds.

Copilot uses AI. Check for mistakes.
@RandithaK RandithaK merged commit 6ae23bc into main Nov 11, 2025
7 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants