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 Review and Reviewed PR Count to Leaderboard Activity #104

Merged
merged 8 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
6 changes: 6 additions & 0 deletions server/application-server/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,12 @@ components:
rank:
type: integer
format: int32
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 @@ -21,6 +21,8 @@ public class LeaderboardEntry {
private UserType type;
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 @@ -56,6 +56,8 @@ public List<LeaderboardEntry> createLeaderboard(Optional<LocalDate> after, Optio
return null;
}
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 @@ -69,6 +71,8 @@ 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());
numberOfReviews.incrementAndGet();
switch (review.getState()) {
case CHANGES_REQUESTED:
changesRequestedSet.add(reviewDTO);
Expand All @@ -88,6 +92,8 @@ 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(),
numberOfReviews.get(),
GODrums marked this conversation as resolved.
Show resolved Hide resolved
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,8 @@ export interface LeaderboardEntry {
type?: LeaderboardEntry.TypeEnum;
score?: number;
rank?: number;
numberOfReviewedPRs?: number;
numberOfReviews?: number;
changesRequested?: Array<PullRequestReviewDTO>;
approvals?: Array<PullRequestReviewDTO>;
comments?: Array<PullRequestReviewDTO>;
Expand Down
11 changes: 11 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,17 @@
<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-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>
<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
5 changes: 4 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, 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 @@ -37,6 +37,9 @@ export class LeaderboardComponent {
protected octFileDiff = octFileDiff;
protected octCheck = octCheck;
protected octComment = octComment;
protected octGitPullRequest = octGitPullRequest;
protected octChevronRight = octChevronRight;
protected octEye = octEye;

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