dev comment all google search
Test Workflow / test (push) Successful in 4s

This commit is contained in:
vladp
2026-03-17 12:32:48 +07:00
parent 95edcdf527
commit e66225cdd1
2 changed files with 51 additions and 50 deletions
@@ -56,31 +56,31 @@ public class MonitoringSearchService {
try { try {
tariffInfoService.writeOffTokens(monitoring.getUserId(), tariffMonitoring.getTokens()); tariffInfoService.writeOffTokens(monitoring.getUserId(), tariffMonitoring.getTokens());
// String yandexResponse = searchImageService.searchReverseByPublicUrl( String yandexResponse = searchImageService.searchReverseByPublicUrl(
// monitoring.getFile(), "yandex_reverse_image", "visual_matches"); monitoring.getFile(), "yandex_reverse_image", "visual_matches");
// List<YandexSearchResponse.ImageResult> yandexImages = List<YandexSearchResponse.ImageResult> yandexImages =
// searchImageService.getAllImagesWithoutPagination(yandexResponse, "visual_matches"); searchImageService.getAllImagesWithoutPagination(yandexResponse, "visual_matches");
//
// for (YandexSearchResponse.ImageResult imageResult : yandexImages) {
// violationService.processViolation(imageResult, monitoring.getFile(), null);
// }
try { for (YandexSearchResponse.ImageResult imageResult : yandexImages) {
String googleResponse = searchImageService.searchReverseByPublicUrl(
monitoring.getFile(), "google_lens", "exact_matches");
List<YandexSearchResponse.ImageResult> googleImages =
searchImageService.getAllImagesWithoutPagination(googleResponse, "exact_matches");
for (YandexSearchResponse.ImageResult imageResult : googleImages) {
violationService.processViolation(imageResult, monitoring.getFile(), null); violationService.processViolation(imageResult, monitoring.getFile(), null);
} }
} catch (TimeoutException | IOException e) { // try {
log.warn("Google search failed"); // String googleResponse = searchImageService.searchReverseByPublicUrl(
} // monitoring.getFile(), "google_lens", "exact_matches");
//
// List<YandexSearchResponse.ImageResult> googleImages =
// searchImageService.getAllImagesWithoutPagination(googleResponse, "exact_matches");
//
//
// for (YandexSearchResponse.ImageResult imageResult : googleImages) {
// violationService.processViolation(imageResult, monitoring.getFile(), null);
// }
//
// } catch (TimeoutException | IOException e) {
// log.warn("Google search failed");
// }
monitoring.setLastRunStatus("SUCCESS"); monitoring.setLastRunStatus("SUCCESS");
} catch (TariffNotFoundException e) { } catch (TariffNotFoundException e) {
@@ -85,51 +85,52 @@ public class GlobalSearchAsyncProcessor {
result = globalSearchResultRepository.save(result); result = globalSearchResultRepository.save(result);
List<YandexSearchResponse.ImageResult> googleImages = new ArrayList<>(); // List<YandexSearchResponse.ImageResult> googleImages = new ArrayList<>();
List<YandexSearchResponse.ImageResult> yandexImages = new ArrayList<>();
List<YandexSearchResponse.ImageResult> allUniqueImages = new ArrayList<>(); List<YandexSearchResponse.ImageResult> allUniqueImages = new ArrayList<>();
boolean hasTimeout = false; boolean hasTimeout = false;
try {
String searchResponseGoogle = searchImageService.searchReverseByPublicUrl(
file, "google_lens", "exact_matches");
googleImages = searchImageService.getAllImagesWithoutPagination(searchResponseGoogle,
"exact_matches");
allUniqueImages.addAll(googleImages);
log.info("Google search OK for file {}", file.getId());
} catch (TimeoutException e) {
log.warn("Google search timeout for file {}", file.getId());
hasTimeout = true;
} catch (IOException e) {
log.error("Google search failed for file {}", file.getId(), e);
}
// try { // try {
// String searchResponseYandex = searchImageService.searchReverseByPublicUrl( // String searchResponseGoogle = searchImageService.searchReverseByPublicUrl(
// file, "yandex_reverse_image", "visual_matches"); // file, "google_lens", "exact_matches");
// //
// List<YandexSearchResponse.ImageResult> yandexImages = // googleImages = searchImageService.getAllImagesWithoutPagination(searchResponseGoogle,
// searchImageService.getAllImagesWithoutPagination(searchResponseYandex, "visual_matches"); // "exact_matches");
//
// allUniqueImages.addAll(yandexImages); // allUniqueImages.addAll(googleImages);
// log.info("Yandex search OK for file {}", file.getId()); // log.info("Google search OK for file {}", file.getId());
// //
// } catch (TimeoutException e) { // } catch (TimeoutException e) {
// log.warn("Yandex search timeout for file {}", file.getId()); // log.warn("Google search timeout for file {}", file.getId());
// hasTimeout = true; // hasTimeout = true;
// } catch (IOException e) { // } catch (IOException e) {
// log.error("Yandex search failed for file {}", file.getId(), e); // log.error("Google search failed for file {}", file.getId(), e);
// } // }
try {
String searchResponseYandex = searchImageService.searchReverseByPublicUrl(
file, "yandex_reverse_image", "visual_matches");
yandexImages =
searchImageService.getAllImagesWithoutPagination(searchResponseYandex, "visual_matches");
allUniqueImages.addAll(yandexImages);
log.info("Yandex search OK for file {}", file.getId());
} catch (TimeoutException e) {
log.warn("Yandex search timeout for file {}", file.getId());
hasTimeout = true;
} catch (IOException e) {
log.error("Yandex search failed for file {}", file.getId(), e);
}
// allUniqueImages = searchImageService.removeDuplicateUrls( // allUniqueImages = searchImageService.removeDuplicateUrls(
// allUniqueImages.stream() // allUniqueImages.stream()
// .filter(img -> img.getUrl() != null) // .filter(img -> img.getUrl() != null)
// .collect(Collectors.toList()), // .collect(Collectors.toList()),
// new ArrayList<>()); // new ArrayList<>());
allUniqueImages = googleImages; allUniqueImages = yandexImages;
for (YandexSearchResponse.ImageResult imageResult : allUniqueImages) { for (YandexSearchResponse.ImageResult imageResult : allUniqueImages) {
violationService.processViolation(imageResult, file, result); violationService.processViolation(imageResult, file, result);