Skip to content

Commit

Permalink
commit stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixTJDietrich committed Oct 25, 2024
1 parent 38a7af8 commit db23fe7
Show file tree
Hide file tree
Showing 25 changed files with 235 additions and 269 deletions.
21 changes: 0 additions & 21 deletions server/application-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,6 @@
<artifactId>therapi-runtime-javadoc</artifactId>
<version>0.15.0</version>
</dependency>
<dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-starter-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
Expand All @@ -144,18 +135,6 @@
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-bom</artifactId>
<version>1.2.2</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.modulith.Modulithic;

@SpringBootApplication
@Modulithic(systemName = "Hephaestus")
public class Application {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.jpa.boot.spi.IntegratorProvider;

import de.tum.in.www1.hephaestus.gitprovider.issuecomment.IssueCommentDTO;
import de.tum.in.www1.hephaestus.gitprovider.pullrequest.PullRequestDTO;
import de.tum.in.www1.hephaestus.gitprovider.repository.RepositoryDTO;
import de.tum.in.www1.hephaestus.gitprovider.user.UserDTO;
import de.tum.in.www1.hephaestus.gitprovider.issue.dto.IssueInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.issuecomment.dto.IssueCommentInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.label.dto.LabelInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.milestone.dto.MilestoneInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.pullrequest.dto.PullRequestInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.pullrequestreview.dto.PullRequestReviewInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.repository.dto.RepositoryInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.user.dto.UserInfoDTO;
import de.tum.in.www1.hephaestus.leaderboard.dto.LeaderboardEntryDTO;
import io.hypersistence.utils.hibernate.type.util.ClassImportIntegrator;

public class ClassImportIntegratorIntegratorProvider implements IntegratorProvider {
Expand All @@ -19,10 +24,19 @@ public List<Integrator> getIntegrators() {
// Accessible DTOs
@SuppressWarnings("rawtypes")
List<Class> classes = new ArrayList<>();
classes.add(UserDTO.class);
classes.add(PullRequestDTO.class);
classes.add(IssueCommentDTO.class);
classes.add(RepositoryDTO.class);
classes.add(UserInfoDTO.class);
classes.add(IssueInfoDTO.class);
classes.add(LabelInfoDTO.class);
classes.add(MilestoneInfoDTO.class);
classes.add(PullRequestInfoDTO.class);
classes.add(IssueCommentInfoDTO.class);

classes.add(PullRequestReviewInfoDTO.class);
classes.add(PullRequestReviewInfoDTO.PullRequest.class);

classes.add(RepositoryInfoDTO.class);

classes.add(LeaderboardEntryDTO.class);

return List.of(new ClassImportIntegrator(classes));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public String admin() {
}

@GetMapping("/me")
public UserInfoDto getGretting(JwtAuthenticationToken auth) {
return new UserInfoDto(
public AuthUserInfoDTO getGretting(JwtAuthenticationToken auth) {
return new AuthUserInfoDTO(
auth.getToken().getClaimAsString(StandardClaimNames.PREFERRED_USERNAME),
auth.getAuthorities().stream().map(GrantedAuthority::getAuthority).toList());
}

public static record UserInfoDto(String name, List<String> roles) {
public static record AuthUserInfoDTO(String name, List<String> roles) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,21 @@ public class Issue extends BaseGitServiceEntity {
private String htmlUrl;

private boolean isLocked;

private OffsetDateTime closedAt;


private int commentsCount;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "author_id")
@ToString.Exclude
private User author;

@ManyToMany
@JoinTable(name = "issue_label", joinColumns = @JoinColumn(name = "issue_id"), inverseJoinColumns = @JoinColumn(name = "label_id"))
@ToString.Exclude
private Set<Label> labels = new HashSet<>();

@ManyToMany
@JoinTable(name = "issue_assignee", joinColumns = @JoinColumn(name = "issue_id"), inverseJoinColumns = @JoinColumn(name = "user_id"))
@ToString.Exclude
Expand All @@ -97,12 +99,15 @@ public enum State {
OPEN, CLOSED
}

public boolean isPullRequest() {
return false;
}

// Ignored GitHub properties:
// - closed_by seems not to be used by webhooks
// - author_association (not provided by our GitHub API client)
// - state_reason
// - reactions
// - active_lock_reason
// - comments (cached number)
// - [remaining urls]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package de.tum.in.www1.hephaestus.gitprovider.issue.dto;

import java.util.List;

import org.springframework.lang.NonNull;

import de.tum.in.www1.hephaestus.gitprovider.issue.Issue.State;
import de.tum.in.www1.hephaestus.gitprovider.label.dto.LabelInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.user.dto.UserInfoDTO;

public record IssueInfoDTO(
@NonNull Long id,
@NonNull Integer number,
@NonNull String title,
@NonNull State state,
@NonNull Integer commentsCount,
UserInfoDTO author,
List<LabelInfoDTO> labels,
List<UserInfoDTO> assignees,
@NonNull String repositoryNameWithOwner,
@NonNull String htmlUrl,
@NonNull String createdAt,
@NonNull String updatedAt
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public Issue update(@NonNull GHIssue source, @NonNull Issue issue) {
issue.setHtmlUrl(source.getHtmlUrl().toString());
issue.setLocked(source.isLocked());
issue.setClosedAt(DateUtil.convertToOffsetDateTime(source.getClosedAt()));
issue.setCommentsCount(issue.getCommentsCount());
return issue;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package de.tum.in.www1.hephaestus.gitprovider.issuecomment.dto;

import org.springframework.lang.NonNull;
import com.fasterxml.jackson.annotation.JsonInclude;

import de.tum.in.www1.hephaestus.gitprovider.common.AuthorAssociation;
import de.tum.in.www1.hephaestus.gitprovider.issue.dto.IssueInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.user.dto.UserInfoDTO;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public record IssueCommentInfoDTO(
@NonNull Long id,
@NonNull AuthorAssociation authorAssociation,
UserInfoDTO author,
IssueInfoDTO issue,
@NonNull String htmlUrl,
@NonNull String createdAt,
@NonNull String updatedAt) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package de.tum.in.www1.hephaestus.gitprovider.label.dto;

import org.springframework.lang.NonNull;

public record LabelInfoDTO(
@NonNull Long id,
@NonNull String name,
@NonNull String color) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package de.tum.in.www1.hephaestus.gitprovider.milestone.dto;

import org.springframework.lang.NonNull;

import de.tum.in.www1.hephaestus.gitprovider.milestone.Milestone.State;

public record MilestoneInfoDTO(
@NonNull Long id,
@NonNull Integer number,
@NonNull State state,
@NonNull String title,
String description,
String closedAt,
String dueOn,
@NonNull String htmlUrl,
@NonNull String createdAt,
@NonNull String updatedAt
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ public class PullRequest extends Issue {
@OneToMany(mappedBy = "pullRequest", cascade = CascadeType.REMOVE, orphanRemoval = true)
@ToString.Exclude
private Set<PullRequestReviewComment> reviewComments = new HashSet<>();


@Override
public boolean isPullRequest() {
return true;
}

// Ignored GitHub properties:
// - rebaseable (not provided by our GitHub API client)
// - head -> "label", "ref", "repo", "sha", "user"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,51 @@
package de.tum.in.www1.hephaestus.gitprovider.pullrequest;

import java.util.Optional;
import java.time.OffsetDateTime;
import java.util.Set;
import java.util.List;

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;

import de.tum.in.www1.hephaestus.gitprovider.pullrequest.dto.PullRequestInfoDTO;

@Repository
public interface PullRequestRepository extends JpaRepository<PullRequest, Long> {

Set<PullRequest> findByAuthor_Login(String authorLogin);

@Query("""
SELECT p
SELECT MIN(p.createdAt)
FROM PullRequest p
WHERE p.author.login = :authorLogin
""")
Optional<OffsetDateTime> firstContributionByAuthorLogin(@Param("authorLogin") String authorLogin);

@Query("""
SELECT new PullRequestInfoDTO(
p.id,
p.number,
p.title,
p.state,
p.commentCount,
new UserInfoDTO(p.author.id, p.author.login, p.author.avatarUrl, p.author.name, p.author.htmlUrl, p.author.createdAt, p.author.updatedAt),
(SELECT new LabelInfoDTO(l.id, l.name, l.color) FROM Label l WHERE l MEMBER OF p.labels ORDER BY l.name),
(SELECT new UserInfoDTO(u.id, u.login, u.avatarUrl, u.name, u.htmlUrl, u.createdAt, u.updatedAt) FROM User u WHERE u MEMBER OF p.assignees ORDER BY u.login),
p.repository.nameWithOwner,
p.additions,
p.deletions,
p.mergedAt,
p.htmlUrl,
p.createdAt,
p.updatedAt)
FROM PullRequest p
JOIN FETCH p.comments
JOIN FETCH p.reviews
WHERE p.id = :id
WHERE (p.author.login = :assigneeLogin OR :assigneeLogin IN (SELECT u.login FROM p.assignees u)) AND p.state IN :states
ORDER BY p.createdAt DESC
""")
Optional<PullRequest> findByIdWithEagerRelations(Long id);
List<PullRequestInfoDTO> findAssignedByLoginAndStates(
@Param("assigneeLogin") String assigneeLogin,
@Param("states") Set<PullRequest.State> states);
}
Loading

0 comments on commit db23fe7

Please sign in to comment.