<commit_before>package ee.pardiralli.service;

import ee.pardiralli.db.DuckRepository;
import ee.pardiralli.db.RaceRepository;
import ee.pardiralli.domain.Duck;
import ee.pardiralli.dto.SearchDTO;
import ee.pardiralli.util.DateConversion;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
@AllArgsConstructor(onConstructor = @__(@Autowired))
@Log4j
public class SearchServiceImpl implements SearchService {
    private final DuckRepository duckRepository;
    private final RaceRepository raceRepository;

    @Override
    public SearchDTO getLatestRaceSearchDTO() {
        return new SearchDTO(DateConversion.getUtilDate(raceRepository.findLastBeginningDate()));
    }

    @Override
    public List<Duck> findDucksByQuery(SearchDTO userQuery) {
        List<Duck> result;

        if (userQuery.hasOnlyIdAndDate()) {
            Duck duck = duckRepository.findBySerialNumber(userQuery.getSerialNumber(), DateConversion.getLocalDate(userQuery.getRaceBeginningDate()));
            result = duck != null ? Collections.singletonList(duck) : Collections.emptyList();

        } else {
            result = duckRepository.findDuck(
                    userQuery.getOwnersFirstName(),
                    userQuery.getOwnersLastName(),
                    userQuery.getBuyersEmail(),
                    userQuery.getOwnersPhoneNr(),
                    DateConversion.getLocalDate(userQuery.getRaceBeginningDate()));
        }<commit_msg>Removed DateConversion method usage #131<commit_after>package ee.pardiralli.service;

import ee.pardiralli.db.DuckRepository;
import ee.pardiralli.db.RaceRepository;
import ee.pardiralli.domain.Duck;
import ee.pardiralli.dto.SearchDTO;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
@AllArgsConstructor(onConstructor = @__(@Autowired))
@Log4j
public class SearchServiceImpl implements SearchService {
    private final DuckRepository duckRepository;
    private final RaceRepository raceRepository;

    @Override
    public SearchDTO getLatestRaceSearchDTO() {
        return new SearchDTO(raceRepository.findLastBeginningDate());
    }

    @Override
    public List<Duck> findDucksByQuery(SearchDTO userQuery) {
        List<Duck> result;

        if (userQuery.hasOnlyIdAndDate()) {
            Duck duck = duckRepository.findBySerialNumber(userQuery.getSerialNumber(), userQuery.getRaceBeginningDate());
            result = duck != null ? Collections.singletonList(duck) : Collections.emptyList();

        } else {
            result = duckRepository.findDuck(
                    userQuery.getOwnersFirstName(),
                    userQuery.getOwnersLastName(),
                    userQuery.getBuyersEmail(),
                    userQuery.getOwnersPhoneNr(),
                    userQuery.getRaceBeginningDate());
        }
{'fraction_non_alphanumeric': 0.08932530883750396, 'fraction_numerical': 0.0028508077288565093, 'mean_word_length': 3.556998556998557, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1369635', 'n_tokens_mistral': 920, 'n_tokens_neox': 886, 'n_words': 150}