Skip to content
Merged
Show file tree
Hide file tree
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
Expand Up @@ -164,6 +164,9 @@ public ApiResponse<GitResponse.RepositoryDeleteResponseDTO> deleteRepository(
3. hasNext가 false가 나올 때까지 반복

💡 응답 필드:
- totalCommitCount: 현재 레포지토리에 저장된 전체 커밋 개수
- connectedCommitCount: 적용사항에 연결된 커밋 개수
- unconnectedCommitCount: 아직 적용사항에 연결되지 않은 커밋 개수
- hasNext: 다음 페이지 존재 여부 (더 불러올 커밋이 있으면 true)
- nextCursorId: 다음 요청에 사용할 커서 ID
- isFirst: 첫 페이지 여부
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/com/whylog/server/domain/git/dto/GitResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public static class CommitDTO {
@Schema(description = "작성자 이름", example = "김준용")
private String authorName;

@Schema(description = "작성자 프로필 사진", example = "https://img.com/profile.jpg")
private String authorProfileImage;

@Schema(description = "커밋 날짜", example = "2026-03-24T10:30:00")
private LocalDateTime dateTime;

Expand All @@ -102,6 +105,7 @@ public static CommitDTO from(Commit commit, ConnectedApplicationDTO connectedApp
.hash(commit.getHash())
.message(commit.getMessage())
.authorName(commit.getAuthorName())
.authorProfileImage(commit.getAuthorProfileImage())
.dateTime(commit.getDateTime())
.addedLines(commit.getAddedLines())
.deletedLines(commit.getDeletedLines())
Expand Down Expand Up @@ -299,6 +303,15 @@ public static class CommitListResponseDTO {
@Schema(description = "현재 페이지의 커밋 개수", example = "10")
private Integer commitListSize;

@Schema(description = "현재 레포지토리에 있는 전체 커밋 개수", example = "123")
private Long totalCommitCount;

@Schema(description = "현재 레포지토리에서 적용사항에 연결된 커밋 개수", example = "80")
private Long connectedCommitCount;

@Schema(description = "현재 레포지토리에서 아직 적용사항에 연결되지 않은 커밋 개수", example = "43")
private Long unconnectedCommitCount;

@Schema(description = "페이지 처음 여부", example = "true")
private Boolean isFirst;

Expand All @@ -311,7 +324,9 @@ public static class CommitListResponseDTO {
public static CommitListResponseDTO from(
Slice<Commit> commitSlice,
Long cursorId,
java.util.Map<Long, CommitDTO.ConnectedApplicationDTO> connectedApplicationsByCommitId
java.util.Map<Long, CommitDTO.ConnectedApplicationDTO> connectedApplicationsByCommitId,
Long totalCommitCount,
Long connectedCommitCount
) {
List<CommitDTO> commitDTOs = commitSlice.getContent().stream()
.map(commit -> CommitDTO.from(commit, connectedApplicationsByCommitId.get(commit.getId())))
Expand All @@ -325,6 +340,9 @@ public static CommitListResponseDTO from(
return CommitListResponseDTO.builder()
.commitDTOList(commitDTOs)
.commitListSize(commitDTOs.size())
.totalCommitCount(totalCommitCount)
.connectedCommitCount(connectedCommitCount)
.unconnectedCommitCount(totalCommitCount - connectedCommitCount)
.isFirst(cursorId == null)
.hasNext(commitSlice.hasNext())
.nextCursorId(nextCursorId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ public interface CommitConnectionRepository extends JpaRepository<CommitConnecti
""")
List<Long> findConnectedCommitIds(@Param("commitIds") List<Long> commitIds);

@Query("""
SELECT COUNT(DISTINCT cc.commit.id)
FROM CommitConnection cc
WHERE cc.commit.repository.id = :repositoryId
""")
long countByRepositoryId(@Param("repositoryId") Long repositoryId);

@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("""
DELETE FROM CommitConnection cc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Set<String> findExistingHashes(
""")
void deleteByRepositoryId(@Param("repositoryId") Long repositoryId);

long countByRepositoryId(Long repositoryId);

// 커서 기반 무한스크롤 - 커밋 목록 조회
@Query("SELECT c FROM Commit c " +
"WHERE c.repository.id = :repositoryId " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public Slice<Commit> getCommitsByRepository(Long repositoryId, Long cursorId) {
public GitResponse.CommitListResponseDTO getCommitListResponse(Long repositoryId, Long cursorId) {
// 커밋 페이지를 조회한 뒤, 각 커밋에 연결된 적용사항을 함께 응답 DTO로 조립
Slice<Commit> commitSlice = getCommitsByRepository(repositoryId, cursorId);
long totalCommitCount = commitRepository.countByRepositoryId(repositoryId);
long connectedCommitCount = commitConnectionRepository.countByRepositoryId(repositoryId);

List<Commit> commits = commitSlice.getContent();
Map<Long, GitResponse.CommitDTO.ConnectedApplicationDTO> connectedApplicationsByCommitId = new LinkedHashMap<>();
Expand All @@ -104,7 +106,13 @@ public GitResponse.CommitListResponseDTO getCommitListResponse(Long repositoryId
);
}

return GitResponse.CommitListResponseDTO.from(commitSlice, cursorId, connectedApplicationsByCommitId);
return GitResponse.CommitListResponseDTO.from(
commitSlice,
cursorId,
connectedApplicationsByCommitId,
totalCommitCount,
connectedCommitCount
);
}

/**
Expand Down
Loading