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

Fix: CHAT-314-채팅-조회-역순-수정 #60

Closed
wants to merge 4 commits 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
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ on:
push:
branches: [ "develop" ]
pull_request:
branches: [ ]
branches: [ "develop" ]

permissions:
contents: read
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
public interface ChatRepository extends JpaRepository<Chat, Long> {

List<Chat> findTop10ByMember_UserIdOrderByChatIdDesc(Long userId);
@Query("SELECT c FROM chat c WHERE c.member.userId = :userId AND c.chatId > :lastChatId ORDER BY c.chatId DESC")
List<Chat> findTop10ByUserIdAndChatIdGreaterThanOrderByChatIdDesc(@Param("userId") Long userId, @Param("lastChatId") Long lastChatId);
@Query("SELECT c FROM chat c WHERE c.member.userId = :userId AND :lastChatId-10 < c.chatId AND c.chatId <= :lastChatId ORDER BY c.chatId ASC")
List<Chat> findTop10ByUserIdAndChatIdLessThanOrderByChatIdDesc(@Param("userId") Long userId, @Param("lastChatId") Long lastChatId);
List<Chat> findTopByMember_UserIdOrderByChatIdDesc(Long userId);
}
2 changes: 1 addition & 1 deletion src/main/java/com/kuit/chatdiary/service/ChatService.java
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ public String extractGptResponse(String jsonResponse) throws JsonProcessingExcep
}

public List<ChatGetResponseDTO> getChats(Long userId, Long lastChatId) {
List<Chat> chats = chatRepository.findTop10ByUserIdAndChatIdGreaterThanOrderByChatIdDesc(userId, lastChatId);
List<Chat> chats = chatRepository.findTop10ByUserIdAndChatIdLessThanOrderByChatIdDesc(userId, lastChatId);
if (chats.isEmpty()) {
return null;
}