-
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.
Merge branch 'develop' into feature/table-component
- Loading branch information
Showing
27 changed files
with
628 additions
and
111 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
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
9 changes: 9 additions & 0 deletions
9
...r/src/main/java/de/tum/in/www1/hephaestus/codereview/repository/RepositoryRepository.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,10 +1,19 @@ | ||
package de.tum.in.www1.hephaestus.codereview.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
@org.springframework.stereotype.Repository | ||
public interface RepositoryRepository | ||
extends JpaRepository<Repository, Long> { | ||
|
||
Repository findByNameWithOwner(String nameWithOwner); | ||
|
||
@Query(""" | ||
SELECT r | ||
FROM Repository r | ||
JOIN FETCH r.pullRequests | ||
WHERE r.nameWithOwner = :nameWithOwner | ||
""") | ||
Repository findByNameWithOwnerWithEagerPullRequests(String nameWithOwner); | ||
} |
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
24 changes: 24 additions & 0 deletions
24
...ion-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardController.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,24 @@ | ||
package de.tum.in.www1.hephaestus.leaderboard; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/leaderboard") | ||
public class LeaderboardController { | ||
|
||
private final LeaderboardService leaderboardService; | ||
|
||
public LeaderboardController(LeaderboardService leaderboardService) { | ||
this.leaderboardService = leaderboardService; | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<List<LeaderboardEntry>> getLeaderboard() { | ||
return ResponseEntity.ok(leaderboardService.createLeaderboard()); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...lication-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardEntry.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,8 @@ | ||
package de.tum.in.www1.hephaestus.leaderboard; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_EMPTY) | ||
public record LeaderboardEntry(String githubName, String name, int score, int total, int changesRequested, | ||
int approvals, int comments) { | ||
} |
52 changes: 52 additions & 0 deletions
52
...cation-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.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,52 @@ | ||
package de.tum.in.www1.hephaestus.leaderboard; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.stereotype.Service; | ||
|
||
import de.tum.in.www1.hephaestus.codereview.user.User; | ||
import de.tum.in.www1.hephaestus.codereview.user.UserService; | ||
|
||
@Service | ||
public class LeaderboardService { | ||
private static final Logger logger = LoggerFactory.getLogger(LeaderboardService.class); | ||
|
||
private final UserService userService; | ||
|
||
public LeaderboardService(UserService userService) { | ||
this.userService = userService; | ||
} | ||
|
||
public List<LeaderboardEntry> createLeaderboard() { | ||
logger.info("Creating leaderboard dataset"); | ||
|
||
List<User> users = userService.getAllUsers(); | ||
logger.info("Found " + users.size() + " users"); | ||
|
||
List<LeaderboardEntry> leaderboard = users.stream().map(user -> { | ||
logger.info("Creating leaderboard entry for user: " + user.getLogin()); | ||
int comments = user.getIssueComments().size(); | ||
AtomicInteger changesRequested = new AtomicInteger(0); | ||
AtomicInteger changesApproved = new AtomicInteger(0); | ||
user.getReviews().stream().forEach(review -> { | ||
switch (review.getState()) { | ||
case CHANGES_REQUESTED: | ||
changesRequested.incrementAndGet(); | ||
break; | ||
case APPROVED: | ||
changesApproved.incrementAndGet(); | ||
break; | ||
default: | ||
break; | ||
} | ||
}); | ||
return new LeaderboardEntry(user.getLogin(), user.getName(), 0, 0, changesRequested.get(), | ||
changesApproved.get(), comments); | ||
}).toList(); | ||
|
||
return leaderboard; | ||
} | ||
} |
Oops, something went wrong.