Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

채팅방 목록 조회 시 쿼리 변경 #751

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package com.ddang.ddang.chat.infrastructure.persistence;

import static com.ddang.ddang.auction.domain.QAuction.auction;
import static com.ddang.ddang.chat.domain.QChatRoom.chatRoom;
import static com.ddang.ddang.chat.domain.QMessage.message;
import static com.ddang.ddang.chat.domain.QReadMessageLog.readMessageLog;
import static com.ddang.ddang.image.domain.QAuctionImage.auctionImage;
import static java.util.Comparator.comparing;

import com.ddang.ddang.chat.domain.dto.ChatRoomAndMessageAndImageDto;
import com.ddang.ddang.chat.infrastructure.persistence.dto.ChatRoomAndMessageAndImageQueryProjectionDto;
import com.ddang.ddang.chat.infrastructure.persistence.dto.QChatRoomAndMessageAndImageQueryProjectionDto;
Expand All @@ -8,18 +15,10 @@
import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.JPQLQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Objects;

import static com.ddang.ddang.auction.domain.QAuction.auction;
import static com.ddang.ddang.chat.domain.QChatRoom.chatRoom;
import static com.ddang.ddang.chat.domain.QMessage.message;
import static com.ddang.ddang.chat.domain.QReadMessageLog.readMessageLog;
import static com.ddang.ddang.image.domain.QAuctionImage.auctionImage;
import static java.util.Comparator.comparing;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

@Repository
@RequiredArgsConstructor
Expand All @@ -43,15 +42,13 @@ public List<ChatRoomAndMessageAndImageDto> findAllChatRoomInfoByUserIdOrderByLas
.select(auctionImage.id.min())
.from(auctionImage)
.where(auctionImage.auction.id.eq(auction.id))
.groupBy(auctionImage.auction.id)
)).fetchJoin()
.leftJoin(auction.lastBid).fetchJoin()
.leftJoin(message).on(message.id.eq(
JPAExpressions
.select(message.id.max())
.from(message)
.where(message.chatRoom.id.eq(chatRoom.id))
.groupBy(message.chatRoom.id)
)).fetchJoin()
.where(isSellerOrWinner(userId))
.fetch();
Expand Down
Loading