Skip to content

Commit

Permalink
Merge pull request #120 from Na-o-man/fix/#119/fix_photoEs_paging
Browse files Browse the repository at this point in the history
[FIX] photos_es 페이지 조회의 결과가 무조건 isLast값이 true인 버그 수정
  • Loading branch information
bflykky authored Aug 15, 2024
2 parents 5c60970 + 58c5b2b commit 1ffaad5
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Page<PhotoEs> findPhotoEsByShareGroupId(Long shareGroupId, Pageable pagea
} catch (IOException e) {
throw new BusinessException(ElasticsearchErrorCode.ELASTICSEARCH_IOEXCEPTION, e);
}
return toPagePhotoEs(response.hits().hits(), pageable);
return toPagePhotoEs(response.hits().hits(), pageable, response.hits().total().value());
}

//특정 공유 그룹의 얼굴이 태그된 사진 검색
Expand Down Expand Up @@ -127,7 +127,7 @@ public Page<PhotoEs> findPhotoEsByShareGroupIdAndFaceTag(Long shareGroupId, Long
throw new BusinessException(ElasticsearchErrorCode.ELASTICSEARCH_IOEXCEPTION, e);
}

return toPagePhotoEs(response.hits().hits(), pageable);
return toPagePhotoEs(response.hits().hits(), pageable,response.hits().total().value());
}

//특정 공유 그룹의 얼굴이 태그되지 않은 사진 검색
Expand Down Expand Up @@ -164,7 +164,7 @@ public Page<PhotoEs> findPhotoEsByShareGroupIdAndNotFaceTag(Long shareGroupId, P
throw new BusinessException(ElasticsearchErrorCode.ELASTICSEARCH_IOEXCEPTION, e);
}

return toPagePhotoEs(response.hits().hits(), pageable);
return toPagePhotoEs(response.hits().hits(), pageable,response.hits().total().value());
}

// rdsId로 ES에서 사진 삭제
Expand Down Expand Up @@ -304,9 +304,11 @@ String esTimeFormat(LocalDateTime localDateTime) {
return localDateTime.format(dateTimeFormatter);
}

private Page<PhotoEs> toPagePhotoEs(List<Hit<PhotoEs>> hits, Pageable pageable) {
List<PhotoEs> photoEsList = hits.stream().map(Hit::source).collect(Collectors.toList());
return new PageImpl<>(photoEsList, pageable, hits.size());
private Page<PhotoEs> toPagePhotoEs(List<Hit<PhotoEs>> hits, Pageable pageable, long total) {
List<PhotoEs> photoEsList = hits.stream()
.map(Hit::source)
.collect(Collectors.toList());
return new PageImpl<>(photoEsList, pageable, total);
}

private int getFrom(Pageable pageable) {
Expand Down

0 comments on commit 1ffaad5

Please sign in to comment.