Skip to content

Commit

Permalink
fix: 월별 집안일 완료 랭킹 조회 api - 네이밍, count() 쿼리하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
daeunkwak committed Sep 20, 2023
1 parent 087dc18 commit a2437b0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public interface HouseWorkCompleteCustomRepository {

List<HouseworkComplete> findMonthlyHouseWorkStatisticByTeamIdAndHouseWorkNameV2(Long memberId, YearMonth from, String houseWorkName);

Long findMonthlyHouseWorkByMember(Long memberId, YearMonth month);
Long getMonthlyCountByMember(Long memberId, YearMonth month);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.depromeet.fairer.domain.houseworkComplete.HouseworkComplete;
import com.depromeet.fairer.vo.houseWorkComplete.HouseWorkCompleteStatisticsVo;
import com.querydsl.core.Tuple;
import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.jpa.impl.JPAQueryFactory;
Expand Down Expand Up @@ -90,16 +89,16 @@ public List<HouseworkComplete> findMonthlyHouseWorkStatisticByTeamIdAndHouseWork
}

@Override
public Long findMonthlyHouseWorkByMember(Long memberId, YearMonth month) {
public Long getMonthlyCountByMember(Long memberId, YearMonth month) {

LocalDateTime startTimeOfMonth = month.atDay(1) .atStartOfDay();
LocalDateTime endTimeOfMonth = month.atEndOfMonth().atTime(LocalTime.MAX);

return (long) jpaQueryFactory.selectFrom(houseworkComplete)
return (long) jpaQueryFactory.select(houseworkComplete.count())
.from(houseWork)
.where(houseworkComplete.member.memberId.eq(memberId),
houseworkComplete.successDateTime.between(startTimeOfMonth, endTimeOfMonth))
.fetch()
.size();
.fetchOne();
}

private BooleanExpression houseworkNameEq(String houseworkName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public MonthlyHouseWorkStatisticResponseDto getMonthlyHouseWorkRanking(Long memb
List<MemberHouseWorkStatisticDto> memberHouseWorkStatisticDtos = new ArrayList<>();
for(Member member : currentMember.getTeam().getMembers()){
memberHouseWorkStatisticDtos.add(
MemberHouseWorkStatisticDto.of(member, houseWorkCompleteRepository.findMonthlyHouseWorkByMember(member.getMemberId(), YearMonth.from(month))));
MemberHouseWorkStatisticDto.of(member, houseWorkCompleteRepository.getMonthlyCountByMember(member.getMemberId(), YearMonth.from(month))));
}

// List<HouseWorkCompleteStatisticsVo> teamHouseWorkStatistics = houseWorkCompleteRepository.findMonthlyHouseWorkRanking(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import java.security.spec.RSAPublicKeySpec;
import java.time.LocalDateTime;
import java.util.*;

@Slf4j
@Service
@Transactional
Expand Down

0 comments on commit a2437b0

Please sign in to comment.