dev comment all yandex search
Test Workflow / test (push) Successful in 5s

This commit is contained in:
vladp
2026-03-17 12:20:19 +07:00
parent 28bc24647a
commit 95edcdf527
2 changed files with 36 additions and 36 deletions
@@ -50,43 +50,43 @@ public class ImageFoundRequestHandler implements RequestHandler {
Map.of("fileId",fileId)));
});
// String searchResponseYandex;
String searchResponseGoogle;
// List<YandexSearchResponse.ImageResult> allYandexImages = new ArrayList<>();
List<YandexSearchResponse.ImageResult> allGoogleImages = new ArrayList<>();
String searchResponseYandex;
// String searchResponseGoogle;
List<YandexSearchResponse.ImageResult> allYandexImages = new ArrayList<>();
// List<YandexSearchResponse.ImageResult> allGoogleImages = new ArrayList<>();
List<YandexSearchResponse.ImageResult> allUniqueImages;
boolean hasTimeout = false;
try {
searchResponseGoogle = searchImageService.searchReverseByPublicUrl(fileEntity, "google_lens",
"exact_matches");
log.info("searchResponseGoogle OK,{}", searchResponseGoogle);
allGoogleImages = searchImageService.getAllImagesWithoutPagination(
searchResponseGoogle, "exact_matches");
} catch (TimeoutException e) {
log.warn("Google search timeout for file {}", fileId);
hasTimeout = true;
} catch (IOException e) {
log.error("Google search failed for file {}", fileId, e);
}
//
// try {
// searchResponseYandex = searchImageService.searchReverseByPublicUrl(fileEntity, "yandex_reverse_image",
// "visual_matches");
// log.info("searchResponseYandex OK");
// allYandexImages = searchImageService.getAllImagesWithoutPagination(
// searchResponseYandex, "visual_matches");
// searchResponseGoogle = searchImageService.searchReverseByPublicUrl(fileEntity, "google_lens",
// "exact_matches");
// log.info("searchResponseGoogle OK,{}", searchResponseGoogle);
// allGoogleImages = searchImageService.getAllImagesWithoutPagination(
// searchResponseGoogle, "exact_matches");
//
// } catch (TimeoutException e) {
// log.warn("Yandex search timeout for file {}", fileId);
// log.warn("Google search timeout for file {}", fileId);
// hasTimeout = true;
// } catch (IOException e) {
// log.error("Yandex search failed for file {}", fileId, e);
// log.error("Google search failed for file {}", fileId, e);
// }
try {
searchResponseYandex = searchImageService.searchReverseByPublicUrl(fileEntity, "yandex_reverse_image",
"visual_matches");
log.info("searchResponseYandex OK");
allYandexImages = searchImageService.getAllImagesWithoutPagination(
searchResponseYandex, "visual_matches");
} catch (TimeoutException e) {
log.warn("Yandex search timeout for file {}", fileId);
hasTimeout = true;
} catch (IOException e) {
log.error("Yandex search failed for file {}", fileId, e);
}
// allUniqueImages = searchImageService.removeDuplicateUrls(allYandexImages, allGoogleImages);
allUniqueImages = allGoogleImages;
// allUniqueImages = allYandexImages;
// allUniqueImages = allGoogleImages;
allUniqueImages = allYandexImages;
log.info("allUniqueImages OK: {} images", allUniqueImages.size());
tariffInfoService.writeOffTokens(fileEntity.getUserId(), TariffConstants.TOKEN_VALUE_FOR_SEARCH);
@@ -32,11 +32,11 @@ public class SearchImageService {
private final OkHttpClient googleHttpClient;
public SearchImageService() {
Proxy proxy = new Proxy(Proxy.Type.HTTP,
new InetSocketAddress("193.46.217.94", 3128));
// Proxy proxy = new Proxy(Proxy.Type.HTTP,
// new InetSocketAddress("193.46.217.94", 3128));
this.yandexHttpClient = new OkHttpClient.Builder()
.proxy(proxy)
// .proxy(proxy)
.connectTimeout(35, TimeUnit.SECONDS)
.writeTimeout(35, TimeUnit.SECONDS)
.readTimeout(35, TimeUnit.SECONDS)
@@ -47,7 +47,7 @@ public class SearchImageService {
.build();
this.googleHttpClient = new OkHttpClient.Builder()
.proxy(proxy)
// .proxy(proxy)
.connectTimeout(35, TimeUnit.SECONDS)
.writeTimeout(35, TimeUnit.SECONDS)
.readTimeout(35, TimeUnit.SECONDS)