From dc1881ffede13e6eeb36fbc52a36c016c8ce499c Mon Sep 17 00:00:00 2001 From: Melina Gutierrez Date: Mon, 25 Nov 2024 19:35:42 -0400 Subject: [PATCH] Arreglar generar un reporte de Horas Trabajadas --- .../repositories/EmployeeRepository.java | 1 + .../com/primefactorsolutions/service/EmployeeService.java | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/primefactorsolutions/repositories/EmployeeRepository.java b/src/main/java/com/primefactorsolutions/repositories/EmployeeRepository.java index a72f647..573763c 100644 --- a/src/main/java/com/primefactorsolutions/repositories/EmployeeRepository.java +++ b/src/main/java/com/primefactorsolutions/repositories/EmployeeRepository.java @@ -11,5 +11,6 @@ public interface EmployeeRepository extends JpaRepository { Optional findByUsername(String username); Optional findByPersonalEmail(String personalEmail); List findAllByTeamId(UUID teamId); + Optional findByTeamIdAndLeadManagerTrue(UUID teamId); List findByTeamName(String teamName); } \ No newline at end of file diff --git a/src/main/java/com/primefactorsolutions/service/EmployeeService.java b/src/main/java/com/primefactorsolutions/service/EmployeeService.java index 1f374e8..b63bb47 100644 --- a/src/main/java/com/primefactorsolutions/service/EmployeeService.java +++ b/src/main/java/com/primefactorsolutions/service/EmployeeService.java @@ -50,12 +50,7 @@ public class EmployeeService { } public String getTeamLeadName(final UUID teamId) { - // Encuentra al empleado con el rol de lead_manager en el equipo especificado - List teamMembers = employeeRepository.findAllByTeamId(teamId); - Optional leadManager = teamMembers.stream() - .filter(e -> Strings.isNullOrEmpty(e.getLeadManager())) - .findFirst(); - + Optional leadManager = employeeRepository.findByTeamIdAndLeadManagerTrue(teamId); return leadManager.map(employee -> employee.getFirstName() + " " + employee.getLastName()) .orElse("No asignado"); }