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

Add first GitHub entities and automatically fetch them for the leaderboard #62

Merged
merged 57 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
8df40a6
(feat): GraphQL + dot Env
GODrums Aug 18, 2024
5ff5a8b
Create GraphQL connection relations
GODrums Aug 18, 2024
8e625b3
fix: add referenced column names
GODrums Aug 18, 2024
bdcca5b
Merge branch 'develop' into feature/github-graphql-artemis
FelixTJDietrich Aug 20, 2024
28c226c
Replace .env with application-local.yml
GODrums Aug 20, 2024
45a6140
fix: transient value error
GODrums Aug 20, 2024
45f228d
Rework for Github API
GODrums Aug 21, 2024
d20d7a5
Merge branch 'develop' into feature/github-graphql-artemis
FelixTJDietrich Aug 23, 2024
37d1d2b
Rework repo fetch
GODrums Aug 24, 2024
78db6d2
Add endpoints for entities
GODrums Aug 25, 2024
fbb09e8
Add entity constructors
GODrums Aug 26, 2024
bae8980
table names to singular
GODrums Aug 28, 2024
d5711f2
replace list with set
GODrums Aug 28, 2024
de9adc4
Add cascade types for actor relations
GODrums Aug 28, 2024
4a372f1
Directly init relation sets
GODrums Aug 28, 2024
85f9e4c
Improve toString printing
GODrums Aug 28, 2024
8a8381b
Replace toString with annotations
GODrums Aug 28, 2024
21d3f7f
Prefer nonnull over nullable column
GODrums Aug 28, 2024
7474b78
Rename Actor, Pullrequest and Comment
GODrums Aug 28, 2024
05ed344
Add user name attribute
GODrums Aug 28, 2024
5b03982
Introduce DTO for user
GODrums Aug 29, 2024
567df15
Replace logger classes
GODrums Aug 29, 2024
1faa0dc
Create GHIssueState enum
GODrums Aug 29, 2024
930a3ef
Deleted unused classes
GODrums Aug 29, 2024
f629070
Remove more unused code
GODrums Aug 29, 2024
6e6b166
Remove github_id from entities
GODrums Aug 29, 2024
7d8df65
Improve entity comments
GODrums Aug 29, 2024
9121e61
Add more DTOs and Superclass
GODrums Aug 30, 2024
322702e
Merge branch 'develop' into feature/github-graphql-artemis
FelixTJDietrich Aug 30, 2024
06528e8
fix indentiation of application.yml
FelixTJDietrich Aug 30, 2024
b58eaea
Merge branch 'develop' into feature/github-graphql-artemis
FelixTJDietrich Aug 30, 2024
bbb2ef7
Implement feedback from review
GODrums Aug 30, 2024
f6b9e7f
Merge branch 'feature/github-graphql-artemis' of https://github.com/l…
GODrums Aug 30, 2024
b93b665
Merge branch 'develop' into feature/github-graphql-artemis
FelixTJDietrich Aug 30, 2024
a9a2410
Improve Entity generation
GODrums Aug 30, 2024
698da27
Merge branch 'feature/github-graphql-artemis' of https://github.com/l…
GODrums Aug 30, 2024
eab0543
Refactor converts with BaseGitServiceEntityConverter
GODrums Aug 30, 2024
cf50f37
Add id to DTOs
GODrums Aug 30, 2024
f9af54a
Add more Repository attributes
GODrums Aug 31, 2024
79a1194
Refactor github sync with cron
GODrums Aug 31, 2024
3588ed7
rename files and pullrequest
FelixTJDietrich Aug 31, 2024
17e6528
Rename scheduler
GODrums Aug 31, 2024
22ead12
Change repositories to fetch
GODrums Aug 31, 2024
e23c516
Redo pullrequest naming
GODrums Sep 1, 2024
3571d40
Make converter services
GODrums Sep 1, 2024
87a2620
Delete EntityNotFoundException
GODrums Sep 1, 2024
5b99ac1
Change to @Component
GODrums Sep 1, 2024
827cb8a
Delete Pullrequest.java
GODrums Sep 2, 2024
8457374
Delete PullrequestRepository.java
GODrums Sep 2, 2024
55e0486
Recommit correct casing files
GODrums Sep 2, 2024
e12ed62
Add default value for ghAuthToken
GODrums Sep 2, 2024
ce402ec
Create a non-environement ghAuthToken
GODrums Sep 2, 2024
21704cf
New OpenAPI specs
GODrums Sep 2, 2024
1530549
Execute generate:api:application-server-client
GODrums Sep 2, 2024
40dfc87
Execute generate:api
GODrums Sep 2, 2024
9b6ca82
Regenerate API from Mac
GODrums Sep 2, 2024
2c822f4
Another openapi regenerate
GODrums Sep 2, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.venv
.DS_Store

# Idea files
.idea/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import org.kohsuke.github.GHObject;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.Date;

@ReadingConverter
public abstract class BaseGitServiceEntityConverter<S extends GHObject, T extends BaseGitServiceEntity>
implements Converter<S, T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import de.tum.in.www1.hephaestus.codereview.base.BaseGitServiceEntity;
import de.tum.in.www1.hephaestus.codereview.pullrequest.PullRequest;
import de.tum.in.www1.hephaestus.codereview.user.User;
import jakarta.persistence.Basic;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.Lob;
import jakarta.persistence.ManyToOne;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -24,6 +26,8 @@
@ToString(callSuper = true)
public class IssueComment extends BaseGitServiceEntity {
@NonNull
@Lob
@Basic(fetch = FetchType.EAGER)
private String body;

@ManyToOne(fetch = FetchType.LAZY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import org.kohsuke.github.GHIssueComment;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;

import de.tum.in.www1.hephaestus.codereview.base.BaseGitServiceEntityConverter;

@Service
GODrums marked this conversation as resolved.
Show resolved Hide resolved
public class IssueCommentConverter extends BaseGitServiceEntityConverter<GHIssueComment, IssueComment> {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package de.tum.in.www1.hephaestus.codereview.pullrequest;

import java.util.Optional;
import java.util.Set;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -17,8 +19,9 @@ public PullRequestController(PullRequestService pullRequestService) {
}

@GetMapping("/{id}")
public PullRequest getPullRequest(@PathVariable Long id) {
return pullRequestService.getPullRequestById(id);
public ResponseEntity<PullRequest> getPullRequest(@PathVariable Long id) {
Optional<PullRequest> pullRequest =pullRequestService.getPullRequestById(id);
return pullRequest.map(ResponseEntity::ok).orElseGet(() -> ResponseEntity.notFound().build());
}

@GetMapping("/author/{login}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package de.tum.in.www1.hephaestus.codereview.pullrequest;

import org.kohsuke.github.GHPullRequest;
import org.springframework.data.convert.ReadingConverter;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;

import de.tum.in.www1.hephaestus.codereview.base.BaseGitServiceEntityConverter;

@Service
@ReadingConverter
public class PullRequestConverter extends BaseGitServiceEntityConverter<GHPullRequest, PullRequest> {
@Override
public PullRequest convert(@NonNull GHPullRequest source) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.tum.in.www1.hephaestus.codereview.pullrequest;

import java.util.Optional;
import java.util.Set;

import org.slf4j.Logger;
Expand All @@ -16,13 +17,13 @@ public PullRequestService(PullRequestRepository pullRequestRepository) {
this.pullRequestRepository = pullRequestRepository;
}

public PullRequest getPullRequestById(Long id) {
logger.info("Getting pullRequest with id: " + id);
return pullRequestRepository.findById(id).orElse(null);
public Optional<PullRequest> getPullRequestById(Long id) {
logger.info("Getting pullRequest with id: {}", id);
return pullRequestRepository.findById(id);
}

public Set<PullRequest> getPullRequestsByAuthor(String login) {
logger.info("Getting pullRequest by author: " + login);
logger.info("Getting pullRequest by author: {}", login);
return pullRequestRepository.findByAuthor_Login(login);
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GHRepository.Visibility;
import org.springframework.data.convert.ReadingConverter;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;

import de.tum.in.www1.hephaestus.codereview.base.BaseGitServiceEntityConverter;

@Service
@ReadingConverter
public class RepositoryConverter extends BaseGitServiceEntityConverter<GHRepository, Repository> {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import java.util.Optional;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import de.tum.in.www1.hephaestus.errors.EntityNotFoundException;

@RestController
@RequestMapping("/user")
public class UserController {
Expand All @@ -19,12 +18,9 @@ public UserController(UserService actorService) {
}

@GetMapping("/{login}")
public UserDTO getUser(@PathVariable String login) {
public ResponseEntity<UserDTO> getUser(@PathVariable String login) {
Optional<UserDTO> user = userService.getUserDTO(login);
if (user.isEmpty()) {
throw new EntityNotFoundException("Actor with login " + login + " not found!");
}
return user.get();
return user.map(ResponseEntity::ok).orElseGet(() -> ResponseEntity.notFound().build());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;

import de.tum.in.www1.hephaestus.codereview.base.BaseGitServiceEntityConverter;

@Service
public class UserConverter extends BaseGitServiceEntityConverter<org.kohsuke.github.GHUser, User> {

protected static final Logger logger = LoggerFactory.getLogger(UserConverter.class);
Expand Down

This file was deleted.

Loading