Arreglar generar un reporte de Horas Trabajadas

This commit is contained in:
Melina Gutierrez 2024-11-25 19:35:42 -04:00
parent 9c1921df9a
commit dc1881ffed
2 changed files with 2 additions and 6 deletions

View File

@ -11,5 +11,6 @@ public interface EmployeeRepository extends JpaRepository<Employee, UUID> {
Optional<Employee> findByUsername(String username); Optional<Employee> findByUsername(String username);
Optional<Employee> findByPersonalEmail(String personalEmail); Optional<Employee> findByPersonalEmail(String personalEmail);
List<Employee> findAllByTeamId(UUID teamId); List<Employee> findAllByTeamId(UUID teamId);
Optional<Employee> findByTeamIdAndLeadManagerTrue(UUID teamId);
List<Employee> findByTeamName(String teamName); List<Employee> findByTeamName(String teamName);
} }

View File

@ -50,12 +50,7 @@ public class EmployeeService {
} }
public String getTeamLeadName(final UUID teamId) { public String getTeamLeadName(final UUID teamId) {
// Encuentra al empleado con el rol de lead_manager en el equipo especificado Optional<Employee> leadManager = employeeRepository.findByTeamIdAndLeadManagerTrue(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()) return leadManager.map(employee -> employee.getFirstName() + " " + employee.getLastName())
.orElse("No asignado"); .orElse("No asignado");
} }