Skip to content

Commit

Permalink
Add PR count to leaderboard activity
Browse files Browse the repository at this point in the history
  • Loading branch information
GODrums committed Sep 25, 2024
1 parent 7b9c90c commit 92c07fb
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions server/application-server/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ components:
rank:
type: integer
format: int32
numberOfReviewedPRs:
type: integer
format: int32
changesRequested:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class LeaderboardEntry {
private UserType type;
private int score;
private int rank;
private int numberOfReviewedPRs;
private PullRequestReviewDTO[] changesRequested;
private PullRequestReviewDTO[] approvals;
private PullRequestReviewDTO[] comments;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public List<LeaderboardEntry> createLeaderboard(Optional<LocalDate> after, Optio
return null;
}
AtomicInteger score = new AtomicInteger(0);
Set<Integer> reviewedPRs = new HashSet<>();
Set<PullRequestReviewDTO> changesRequestedSet = new HashSet<>();
Set<PullRequestReviewDTO> approvedSet = new HashSet<>();
Set<PullRequestReviewDTO> commentSet = new HashSet<>();
Expand All @@ -69,6 +70,7 @@ public List<LeaderboardEntry> createLeaderboard(Optional<LocalDate> after, Optio
PullRequestReviewDTO reviewDTO = new PullRequestReviewDTO(review.getId(), review.getCreatedAt(),
review.getUpdatedAt(), review.getSubmittedAt(), review.getState());

reviewedPRs.add(review.getPullRequest().getNumber());
switch (review.getState()) {
case CHANGES_REQUESTED:
changesRequestedSet.add(reviewDTO);
Expand All @@ -88,6 +90,7 @@ public List<LeaderboardEntry> createLeaderboard(Optional<LocalDate> after, Optio
return new LeaderboardEntry(user.getLogin(), user.getAvatarUrl(), user.getName(), user.getType(),
score.get(),
0, // preliminary rank
reviewedPRs.size(),
changesRequestedSet.toArray(new PullRequestReviewDTO[changesRequestedSet.size()]),
approvedSet.toArray(new PullRequestReviewDTO[approvedSet.size()]),
commentSet.toArray(new PullRequestReviewDTO[commentSet.size()]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface LeaderboardEntry {
type?: LeaderboardEntry.TypeEnum;
score?: number;
rank?: number;
numberOfReviewedPRs?: number;
changesRequested?: Array<PullRequestReviewDTO>;
approvals?: Array<PullRequestReviewDTO>;
comments?: Array<PullRequestReviewDTO>;
Expand Down
7 changes: 7 additions & 0 deletions webapp/src/app/home/leaderboard/leaderboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
<td appTableCell class="text-center">{{ entry.score }}</td>
<td appTableCell class="py-2">
<div class="flex items-center gap-3">
<div class="flex items-center gap-1 text-github-foreground" title="Total reviewed PRs">
<ng-icon [svg]="octGitPullRequest" size="16" />
{{ entry.numberOfReviewedPRs }}
</div>
<div class="flex items-center text-github-neutral-foreground">
<ng-icon [svg]="octChevronRight" size="16" />
</div>
@if (entry.changesRequested && entry.changesRequested.length > 0) {
<div class="flex items-center gap-1 text-github-danger-foreground" title="Changes Requested">
<ng-icon [svg]="octFileDiff" size="16" />
Expand Down
4 changes: 3 additions & 1 deletion webapp/src/app/home/leaderboard/leaderboard.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, input } from '@angular/core';
import { NgIconComponent } from '@ng-icons/core';
import { octFileDiff, octCheck, octComment } from '@ng-icons/octicons';
import { octFileDiff, octCheck, octComment, octGitPullRequest, octChevronRight } from '@ng-icons/octicons';
import { LeaderboardEntry } from 'app/core/modules/openapi';
import { AvatarFallbackComponent } from 'app/ui/avatar/avatar-fallback.component';
import { AvatarImageComponent } from 'app/ui/avatar/avatar-image.component';
Expand Down Expand Up @@ -37,6 +37,8 @@ export class LeaderboardComponent {
protected octFileDiff = octFileDiff;
protected octCheck = octCheck;
protected octComment = octComment;
protected octGitPullRequest = octGitPullRequest;
protected octChevronRight = octChevronRight;

leaderboard = input<LeaderboardEntry[]>();
}

0 comments on commit 92c07fb

Please sign in to comment.