Add logs (#37)

* Fix shop and wallets search

* Add logs

* Update DeanonimusServiceHandler.java
This commit is contained in:
malkoas 2023-11-28 10:41:34 +03:00 committed by GitHub
parent f9f8fed656
commit 0c72fda474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,10 +12,15 @@ import dev.vality.deanonimus.domain.Party;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.opensearch.client.opensearch.core.SearchResponse;
import org.opensearch.client.opensearch.core.search.Hit;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import static java.util.stream.Collectors.toList;
@Slf4j
@Component
@RequiredArgsConstructor
@ -30,6 +35,8 @@ public class DeanonimusServiceHandler implements DeanonimusSrv.Iface {
public List<SearchHit> searchParty(String text) {
log.info("Incoming request for party with text: {}", text);
SearchResponse<Party> searchHits = searchDao.searchParty(text);
var parties = searchHits.hits().hits().stream().map(Hit::source).collect(toList());
log.info("Found for party search parties: {}", parties);
var foundSearchHits = searchHitConverter.convert(searchHits);
log.info("Found party: {}", foundSearchHits);
return foundSearchHits;
@ -39,6 +46,8 @@ public class DeanonimusServiceHandler implements DeanonimusSrv.Iface {
public List<SearchShopHit> searchShopText(String text) {
log.info("Incoming request for shop with text: {}", text);
SearchResponse<Party> searchHits = searchDao.searchParty(text);
var parties = searchHits.hits().hits().stream().map(Hit::source).collect(toList());
log.info("Found for shop search parties: {}", parties);
var foundSearchHits = searchHitShopConverter.convert(searchHits);
log.info("Found shop: {}", foundSearchHits);
return foundSearchHits;
@ -48,6 +57,8 @@ public class DeanonimusServiceHandler implements DeanonimusSrv.Iface {
public List<SearchWalletHit> searchWalletText(String text) {
log.info("Incoming request for wallets with text: {}", text);
SearchResponse<Party> searchHits = searchDao.searchParty(text);
var parties = searchHits.hits().hits().stream().map(Hit::source).collect(toList());
log.info("Found for wallet search parties: {}", parties);
var foundSearchHits = searchHitWalletConverter.convert(searchHits);
log.info("Found wallet: {}", foundSearchHits);
return foundSearchHits;