dev change to visual_matches engine
Test Workflow / test (push) Successful in 3s

This commit is contained in:
vladp
2026-02-11 17:41:48 +07:00
parent 970e0fa615
commit 081ca05f88
3 changed files with 265 additions and 264 deletions
@@ -8,12 +8,13 @@ import ru.soune.nocopy.dto.BaseRequest;
import ru.soune.nocopy.dto.BaseResponse;
import ru.soune.nocopy.dto.MessageCode;
import ru.soune.nocopy.dto.file.ImageSearchRequest;
import ru.soune.nocopy.dto.file.YandexSearchResponse;
import ru.soune.nocopy.entity.file.FileEntity;
import ru.soune.nocopy.exception.NotValidFieldException;
import ru.soune.nocopy.repository.FileEntityRepository;
import ru.soune.nocopy.service.file.CheckCounterService;
import ru.soune.nocopy.service.search.SearchApiToYandexResponseMapper;
import ru.soune.nocopy.service.search.YandexSearchService;
import ru.soune.nocopy.service.search.SearchImageService;
import ru.soune.nocopy.service.search.GoogleVisionSearchService;
import ru.soune.nocopy.service.tariff.TariffConstants;
import ru.soune.nocopy.service.tariff.TariffInfoService;
@@ -30,7 +31,7 @@ public class ImageFoundRequestHandler implements RequestHandler {
private final ObjectMapper objectMapper;
private final YandexSearchService yandexSearchService;
private final SearchImageService searchImageService;
private final GoogleVisionSearchService googleVisionSearchService;
@@ -61,9 +62,11 @@ public class ImageFoundRequestHandler implements RequestHandler {
//TODO uncommited when add billing
// GoogleVisionSearchResponse googleVisionSearchResponse = googleVisionSearchService.searchByFileEntity(fileId);
String yandexReverseSearchResponse;
String searchResponseYandex;
String searchResponseGoogle;
try {
yandexReverseSearchResponse = yandexSearchService.searchReverseByPublicUrlWithTimeout(fileEntity);
searchResponseYandex = searchImageService.searchReverseByPublicUrl(fileEntity, "yandex_reverse_image");
searchResponseGoogle = searchImageService.searchReverseByPublicUrl(fileEntity, "google_lens");
} catch (TimeoutException e) {
log.warn("Search timeout for file {}, returning empty results", fileId);
return new BaseResponse(request.getMsgId(), MessageCode.SUCCESS.getCode(),
@@ -85,8 +88,14 @@ public class ImageFoundRequestHandler implements RequestHandler {
int page = imageSearchRequest.getPage() != null ? imageSearchRequest.getPage() : 1;
YandexSearchResponse yandexSearchResponse = mapper.mapToYandexResponse(searchResponseYandex, page, 5);
YandexSearchResponse googleSearchResponse = mapper.mapToYandexResponse(searchResponseGoogle, page, 5);
List<YandexSearchResponse.ImageResult> results = yandexSearchResponse.getImages();
results.addAll(googleSearchResponse.getImages());
yandexSearchResponse.setImages(results);
return new BaseResponse(request.getMsgId(), MessageCode.SUCCESS.getCode(),
MessageCode.SUCCESS.getDescription(), mapper.mapToYandexResponse(yandexReverseSearchResponse, page,
10));
MessageCode.SUCCESS.getDescription(), yandexSearchResponse);
}
}