Skip to content

Commit

Permalink
Add Number of Reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
GODrums committed Sep 25, 2024
1 parent 92c07fb commit 02e00b8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions server/application-server/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ components:
numberOfReviewedPRs:
type: integer
format: int32
numberOfReviews:
type: integer
format: int32
changesRequested:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class LeaderboardEntry {
private int score;
private int rank;
private int numberOfReviewedPRs;
private int numberOfReviews;
private PullRequestReviewDTO[] changesRequested;
private PullRequestReviewDTO[] approvals;
private PullRequestReviewDTO[] comments;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public List<LeaderboardEntry> createLeaderboard(Optional<LocalDate> after, Optio
}
AtomicInteger score = new AtomicInteger(0);
Set<Integer> reviewedPRs = new HashSet<>();
AtomicInteger numberOfReviews = new AtomicInteger(0);
Set<PullRequestReviewDTO> changesRequestedSet = new HashSet<>();
Set<PullRequestReviewDTO> approvedSet = new HashSet<>();
Set<PullRequestReviewDTO> commentSet = new HashSet<>();
Expand All @@ -71,6 +72,7 @@ public List<LeaderboardEntry> createLeaderboard(Optional<LocalDate> after, Optio
review.getUpdatedAt(), review.getSubmittedAt(), review.getState());

reviewedPRs.add(review.getPullRequest().getNumber());
numberOfReviews.incrementAndGet();
switch (review.getState()) {
case CHANGES_REQUESTED:
changesRequestedSet.add(reviewDTO);
Expand All @@ -91,6 +93,7 @@ public List<LeaderboardEntry> createLeaderboard(Optional<LocalDate> after, Optio
score.get(),
0, // preliminary rank
reviewedPRs.size(),
numberOfReviews.get(),
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 @@ -20,6 +20,7 @@ export interface LeaderboardEntry {
score?: number;
rank?: number;
numberOfReviewedPRs?: number;
numberOfReviews?: number;
changesRequested?: Array<PullRequestReviewDTO>;
approvals?: Array<PullRequestReviewDTO>;
comments?: Array<PullRequestReviewDTO>;
Expand Down
6 changes: 5 additions & 1 deletion webapp/src/app/home/leaderboard/leaderboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
<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">
<div class="flex items-center gap-1 text-github-muted-foreground" title="Total number of reviews">
<ng-icon [svg]="octEye" size="16" />
{{ entry.numberOfReviews }}
</div>
<div class="flex items-center gap-1 text-github-muted-foreground" title="Total reviewed PRs">
<ng-icon [svg]="octGitPullRequest" size="16" />
{{ entry.numberOfReviewedPRs }}
</div>
Expand Down
3 changes: 2 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, octGitPullRequest, octChevronRight } from '@ng-icons/octicons';
import { octFileDiff, octCheck, octComment, octGitPullRequest, octChevronRight, octEye } 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 @@ -39,6 +39,7 @@ export class LeaderboardComponent {
protected octComment = octComment;
protected octGitPullRequest = octGitPullRequest;
protected octChevronRight = octChevronRight;
protected octEye = octEye;

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

0 comments on commit 02e00b8

Please sign in to comment.