-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db23fe7
commit b4c3b06
Showing
33 changed files
with
458 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...rver/src/main/java/de/tum/in/www1/hephaestus/gitprovider/label/dto/LabelDTOConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.tum.in.www1.hephaestus.gitprovider.label.dto; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import de.tum.in.www1.hephaestus.gitprovider.label.Label; | ||
|
||
@Component | ||
public class LabelDTOConverter { | ||
|
||
public LabelInfoDTO convertToDTO(Label label) { | ||
return new LabelInfoDTO( | ||
label.getId(), | ||
label.getName(), | ||
label.getColor()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...in/java/de/tum/in/www1/hephaestus/gitprovider/pullrequest/dto/PullRequestBaseInfoDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package de.tum.in.www1.hephaestus.gitprovider.pullrequest.dto; | ||
|
||
import org.springframework.lang.NonNull; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
import de.tum.in.www1.hephaestus.gitprovider.issue.Issue.State; | ||
import de.tum.in.www1.hephaestus.gitprovider.repository.dto.RepositoryInfoDTO; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_EMPTY) | ||
public record PullRequestBaseInfoDTO( | ||
@NonNull Long id, | ||
@NonNull Integer number, | ||
@NonNull String title, | ||
@NonNull State state, | ||
RepositoryInfoDTO repository, | ||
@NonNull String htmlUrl) { | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
...n/java/de/tum/in/www1/hephaestus/gitprovider/pullrequest/dto/PullRequestDTOConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package de.tum.in.www1.hephaestus.gitprovider.pullrequest.dto; | ||
|
||
import java.util.Comparator; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import de.tum.in.www1.hephaestus.gitprovider.label.dto.LabelDTOConverter; | ||
import de.tum.in.www1.hephaestus.gitprovider.label.dto.LabelInfoDTO; | ||
import de.tum.in.www1.hephaestus.gitprovider.pullrequest.PullRequest; | ||
import de.tum.in.www1.hephaestus.gitprovider.repository.dto.RepositoryDTOConverter; | ||
import de.tum.in.www1.hephaestus.gitprovider.user.dto.UserDTOConverter; | ||
import de.tum.in.www1.hephaestus.gitprovider.user.dto.UserInfoDTO; | ||
|
||
@Component | ||
public class PullRequestDTOConverter { | ||
|
||
private final LabelDTOConverter labelDTOConverter; | ||
private final UserDTOConverter userDTOConverter; | ||
private final RepositoryDTOConverter repositoryDTOConverter; | ||
|
||
public PullRequestDTOConverter( | ||
LabelDTOConverter labelDTOConverter, | ||
UserDTOConverter userDTOConverter, | ||
RepositoryDTOConverter repositoryDTOConverter) { | ||
this.labelDTOConverter = labelDTOConverter; | ||
this.userDTOConverter = userDTOConverter; | ||
this.repositoryDTOConverter = repositoryDTOConverter; | ||
} | ||
|
||
public PullRequestInfoDTO convertToDTO(PullRequest pullRequest) { | ||
return new PullRequestInfoDTO( | ||
pullRequest.getId(), | ||
pullRequest.getNumber(), | ||
pullRequest.getTitle(), | ||
pullRequest.getState(), | ||
pullRequest.getCommentsCount(), | ||
userDTOConverter.convertToDTO(pullRequest.getAuthor()), | ||
pullRequest.getLabels() | ||
.stream() | ||
.map(labelDTOConverter::convertToDTO) | ||
.sorted(Comparator.comparing(LabelInfoDTO::name)) | ||
.toList(), | ||
pullRequest.getAssignees() | ||
.stream() | ||
.map(userDTOConverter::convertToDTO) | ||
.sorted(Comparator.comparing(UserInfoDTO::login)) | ||
.toList(), | ||
repositoryDTOConverter.convertToDTO(pullRequest.getRepository()), | ||
pullRequest.getAdditions(), | ||
pullRequest.getDeletions(), | ||
pullRequest.getMergedAt(), | ||
pullRequest.getClosedAt(), | ||
pullRequest.getHtmlUrl(), | ||
pullRequest.getCreatedAt(), | ||
pullRequest.getUpdatedAt()); | ||
} | ||
|
||
public PullRequestBaseInfoDTO convertToBaseDTO(PullRequest pullRequest) { | ||
return new PullRequestBaseInfoDTO( | ||
pullRequest.getId(), | ||
pullRequest.getNumber(), | ||
pullRequest.getTitle(), | ||
pullRequest.getState(), | ||
repositoryDTOConverter.convertToDTO(pullRequest.getRepository()), | ||
pullRequest.getHtmlUrl()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 32 additions & 6 deletions
38
.../de/tum/in/www1/hephaestus/gitprovider/pullrequestreview/PullRequestReviewRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,49 @@ | ||
package de.tum.in.www1.hephaestus.gitprovider.pullrequestreview; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface PullRequestReviewRepository extends JpaRepository<PullRequestReview, Long> { | ||
|
||
Optional<PullRequestReview> findByAuthor_Login(String authorLogin); | ||
|
||
Optional<PullRequestReview> findByPullRequest(PullRequestReview pullRequest); | ||
@Query(""" | ||
SELECT prr | ||
FROM PullRequestReview prr | ||
JOIN FETCH prr.author | ||
JOIN FETCH prr.pullRequest | ||
JOIN FETCH prr.pullRequest.repository | ||
JOIN FETCH prr.comments | ||
WHERE prr.author.login = :authorLogin AND prr.submittedAt >= :activitySince | ||
ORDER BY prr.submittedAt DESC | ||
""") | ||
List<PullRequestReview> findAllByAuthorLoginSince( | ||
@Param("authorLogin") String authorLogin, | ||
@Param("activitySince") OffsetDateTime activitySince); | ||
|
||
@Query(""" | ||
SELECT pr | ||
FROM PullRequestReview pr | ||
JOIN FETCH pr.comments | ||
WHERE pr.id = :reviewId | ||
SELECT prr | ||
FROM PullRequestReview prr | ||
JOIN FETCH prr.author | ||
JOIN FETCH prr.pullRequest | ||
JOIN FETCH prr.pullRequest.repository | ||
JOIN FETCH prr.comments | ||
WHERE | ||
prr.submittedAt BETWEEN :after AND :before | ||
AND (:repository IS NULL OR prr.pullRequest.repository.nameWithOwner = :repository) | ||
AND prr.author.type = 'USER' | ||
ORDER BY prr.submittedAt DESC | ||
""") | ||
Optional<PullRequestReview> findByIdWithEagerComments(Long reviewId); | ||
List<PullRequestReview> findAllInTimeframe( | ||
@Param("after") OffsetDateTime after, | ||
@Param("before") OffsetDateTime before, | ||
@Param("repository") Optional<String> repository); | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...m/in/www1/hephaestus/gitprovider/pullrequestreview/dto/PullRequestReviewDTOConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package de.tum.in.www1.hephaestus.gitprovider.pullrequestreview.dto; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import de.tum.in.www1.hephaestus.gitprovider.pullrequest.dto.PullRequestDTOConverter; | ||
import de.tum.in.www1.hephaestus.gitprovider.pullrequestreview.PullRequestReview; | ||
import de.tum.in.www1.hephaestus.gitprovider.user.dto.UserDTOConverter; | ||
|
||
@Component | ||
public class PullRequestReviewDTOConverter { | ||
|
||
private final UserDTOConverter userDTOConverter; | ||
private final PullRequestDTOConverter pullRequestDTOConverter; | ||
|
||
public PullRequestReviewDTOConverter(UserDTOConverter userDTOConverter, | ||
PullRequestDTOConverter pullRequestDTOConverter) { | ||
this.userDTOConverter = userDTOConverter; | ||
this.pullRequestDTOConverter = pullRequestDTOConverter; | ||
} | ||
|
||
public PullRequestReviewInfoDTO convertToDTO(PullRequestReview pullRequestReview) { | ||
return new PullRequestReviewInfoDTO( | ||
pullRequestReview.getId(), | ||
pullRequestReview.isDismissed(), | ||
pullRequestReview.getState(), | ||
pullRequestReview.getComments().size(), | ||
userDTOConverter.convertToDTO(pullRequestReview.getAuthor()), | ||
pullRequestDTOConverter.convertToBaseDTO(pullRequestReview.getPullRequest()), | ||
pullRequestReview.getHtmlUrl(), | ||
pullRequestReview.getSubmittedAt()); | ||
} | ||
} |
Oops, something went wrong.