This commit is contained in:
@@ -56,15 +56,15 @@ 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) {
|
// for (YandexSearchResponse.ImageResult imageResult : yandexImages) {
|
||||||
violationService.processViolation(imageResult, monitoring.getFile(), null);
|
// violationService.processViolation(imageResult, monitoring.getFile(), null);
|
||||||
}
|
// }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String googleResponse = searchImageService.searchReverseByPublicUrl(
|
String googleResponse = searchImageService.searchReverseByPublicUrl(
|
||||||
|
|||||||
@@ -85,15 +85,16 @@ public class GlobalSearchAsyncProcessor {
|
|||||||
|
|
||||||
result = globalSearchResultRepository.save(result);
|
result = globalSearchResultRepository.save(result);
|
||||||
|
|
||||||
List<YandexSearchResponse.ImageResult> allUniqueImages = new ArrayList<>();
|
List<YandexSearchResponse.ImageResult> googleImages = new ArrayList<>();
|
||||||
|
List<YandexSearchResponse.ImageResult> allUniqueImages = new ArrayList<>();
|
||||||
boolean hasTimeout = false;
|
boolean hasTimeout = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String searchResponseGoogle = searchImageService.searchReverseByPublicUrl(
|
String searchResponseGoogle = searchImageService.searchReverseByPublicUrl(
|
||||||
file, "google_lens", "exact_matches");
|
file, "google_lens", "exact_matches");
|
||||||
|
|
||||||
List<YandexSearchResponse.ImageResult> googleImages =
|
googleImages = searchImageService.getAllImagesWithoutPagination(searchResponseGoogle,
|
||||||
searchImageService.getAllImagesWithoutPagination(searchResponseGoogle, "exact_matches");
|
"exact_matches");
|
||||||
|
|
||||||
allUniqueImages.addAll(googleImages);
|
allUniqueImages.addAll(googleImages);
|
||||||
log.info("Google search OK for file {}", file.getId());
|
log.info("Google search OK for file {}", file.getId());
|
||||||
@@ -105,28 +106,30 @@ public class GlobalSearchAsyncProcessor {
|
|||||||
log.error("Google search failed for file {}", file.getId(), e);
|
log.error("Google search failed for file {}", file.getId(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
String searchResponseYandex = searchImageService.searchReverseByPublicUrl(
|
// String searchResponseYandex = searchImageService.searchReverseByPublicUrl(
|
||||||
file, "yandex_reverse_image", "visual_matches");
|
// file, "yandex_reverse_image", "visual_matches");
|
||||||
|
//
|
||||||
|
// List<YandexSearchResponse.ImageResult> yandexImages =
|
||||||
|
// searchImageService.getAllImagesWithoutPagination(searchResponseYandex, "visual_matches");
|
||||||
|
|
||||||
List<YandexSearchResponse.ImageResult> yandexImages =
|
// allUniqueImages.addAll(yandexImages);
|
||||||
searchImageService.getAllImagesWithoutPagination(searchResponseYandex, "visual_matches");
|
// 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.addAll(yandexImages);
|
// allUniqueImages = searchImageService.removeDuplicateUrls(
|
||||||
log.info("Yandex search OK for file {}", file.getId());
|
// allUniqueImages.stream()
|
||||||
|
// .filter(img -> img.getUrl() != null)
|
||||||
|
// .collect(Collectors.toList()),
|
||||||
|
// new ArrayList<>());
|
||||||
|
|
||||||
} catch (TimeoutException e) {
|
allUniqueImages = googleImages;
|
||||||
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.stream()
|
|
||||||
.filter(img -> img.getUrl() != null)
|
|
||||||
.collect(Collectors.toList()),
|
|
||||||
new ArrayList<>());
|
|
||||||
|
|
||||||
for (YandexSearchResponse.ImageResult imageResult : allUniqueImages) {
|
for (YandexSearchResponse.ImageResult imageResult : allUniqueImages) {
|
||||||
violationService.processViolation(imageResult, file, result);
|
violationService.processViolation(imageResult, file, result);
|
||||||
|
|||||||
Reference in New Issue
Block a user