class MetricService {

    public Map<String, Long> getNumberOfPes(LocalDateTime fromLocalDate, LocalDateTime toLocalDate, StatusType statusType) {
        Map<String, Long> listNumberPesByType = new HashMap<>();

        if(statusType == null) {
            for (StatusType type : StatusType.values()) {
                listNumberPesByType.put(
                        type.name(),
                        pesHistoryRepository.countByDateBetweenAndStatus(fromLocalDate, toLocalDate, type));
            }
        } else {
            listNumberPesByType.put(
                    statusType.name(),
                    pesHistoryRepository.countByDateBetweenAndStatus(fromLocalDate, toLocalDate, statusType));
        }
        return listNumberPesByType;
    }

    @Autowired public  MetricService(PesHistoryRepository pesHistoryRepository);

}