corregir metodo de getTeamLeadName
All checks were successful
PR Builder / Build-PR (pull_request) Successful in 2m47s

This commit is contained in:
alex 2024-11-24 20:46:35 -05:00
parent 0e142934fa
commit 00810b3f6d
2 changed files with 6 additions and 3 deletions

View File

@ -9,8 +9,7 @@ import java.util.UUID;
public interface EmployeeRepository extends JpaRepository<Employee, UUID> {
Optional<Employee> findByUsername(String username);
Optional<Employee> findByPersonalEmail(String personalEmail);
Optional<Employee> findByTeamId(UUID teamId);
List<Employee> findAllByTeamId(UUID teamId);
List<Employee> findByTeamName(String teamName);
}

View File

@ -1,4 +1,5 @@
package com.primefactorsolutions.service;
import com.google.common.base.Strings;
import com.primefactorsolutions.model.Employee;
import jakarta.persistence.EntityManager;
import lombok.AllArgsConstructor;
@ -50,7 +51,10 @@ public class EmployeeService {
public String getTeamLeadName(final UUID teamId) {
// Encuentra al empleado con el rol de lead_manager en el equipo especificado
Optional<Employee> leadManager = employeeRepository.findByTeamId(teamId);
List<Employee> teamMembers = employeeRepository.findAllByTeamId(teamId);
Optional<Employee> leadManager = teamMembers.stream()
.filter(e -> Strings.isNullOrEmpty(e.getLeadManager()))
.findFirst();
return leadManager.map(employee -> employee.getFirstName() + " " + employee.getLastName())
.orElse("No asignado");