Skip to content

Commit

Permalink
Merge pull request #94 from chaee813/feat/refactor-yc
Browse files Browse the repository at this point in the history
포트폴리오 평균 거래가격 계산 로직 수정
  • Loading branch information
1jeongg authored Oct 14, 2023
2 parents e1454b1 + 7d3be8c commit e3fea4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static Long calculateConfirmedQuotationPrice(List<Quotation> quotations)
}

public static Long calculateAvgPrice(List<Match> matches, Long contractCount) {
if (contractCount.equals(0L)) return 0L;
return matches.stream()
.filter(match -> match.getStatus().equals(MatchStatus.CONFIRMED))
.mapToLong(Match::getConfirmedPrice)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,19 @@ public PortfolioResponse.FindByIdDTO getPortfolioById(Long id) {
throw new NotFoundException(BaseException.PORTFOLIO_NOT_FOUND);
}

Portfolio portfolio = imageItems.get(0).getPortfolio();
Planner planner = imageItems.get(0).getPortfolio().getPlanner();
// 플래너 탈퇴 시 조회 X
if (planner == null) {
throw new NotFoundException(BaseException.PORTFOLIO_NOT_FOUND);
}

List<String> images = imageItems
.stream()
.map(ImageEncoder::encode)
.toList();

List<PriceItem> priceItems = priceItemJPARepository.findAllByPortfolioId(id);
Portfolio portfolio = imageItems.get(0).getPortfolio();
Planner planner = portfolio.getPlanner();

// 거래 내역 조회를 위한 매칭 내역, 견적서 가져오기
List<Match> matches = matchJPARepository.findLatestTenByPlanner(planner);
Expand Down

0 comments on commit e3fea4b

Please sign in to comment.