From 92c07fbcd4ff33b2b4d07c7df3d302bc09250888 Mon Sep 17 00:00:00 2001 From: GODrums Date: Wed, 25 Sep 2024 17:48:15 +0200 Subject: [PATCH 1/6] Add PR count to leaderboard activity --- server/application-server/openapi.yaml | 3 +++ .../in/www1/hephaestus/leaderboard/LeaderboardEntry.java | 1 + .../in/www1/hephaestus/leaderboard/LeaderboardService.java | 3 +++ .../app/core/modules/openapi/model/leaderboard-entry.ts | 1 + webapp/src/app/home/leaderboard/leaderboard.component.html | 7 +++++++ webapp/src/app/home/leaderboard/leaderboard.component.ts | 4 +++- 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/server/application-server/openapi.yaml b/server/application-server/openapi.yaml index a193b0d2..1e0fb315 100644 --- a/server/application-server/openapi.yaml +++ b/server/application-server/openapi.yaml @@ -465,6 +465,9 @@ components: rank: type: integer format: int32 + numberOfReviewedPRs: + type: integer + format: int32 changesRequested: type: array items: diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardEntry.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardEntry.java index 28115cf1..a0dafb54 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardEntry.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardEntry.java @@ -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; diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java index fbb495f6..a031c407 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java @@ -56,6 +56,7 @@ public List createLeaderboard(Optional after, Optio return null; } AtomicInteger score = new AtomicInteger(0); + Set reviewedPRs = new HashSet<>(); Set changesRequestedSet = new HashSet<>(); Set approvedSet = new HashSet<>(); Set commentSet = new HashSet<>(); @@ -69,6 +70,7 @@ public List createLeaderboard(Optional 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); @@ -88,6 +90,7 @@ public List createLeaderboard(Optional 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()])); diff --git a/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts b/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts index eeb83ebf..e65a9c77 100644 --- a/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts +++ b/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts @@ -19,6 +19,7 @@ export interface LeaderboardEntry { type?: LeaderboardEntry.TypeEnum; score?: number; rank?: number; + numberOfReviewedPRs?: number; changesRequested?: Array; approvals?: Array; comments?: Array; diff --git a/webapp/src/app/home/leaderboard/leaderboard.component.html b/webapp/src/app/home/leaderboard/leaderboard.component.html index 8eab294a..59cd9368 100644 --- a/webapp/src/app/home/leaderboard/leaderboard.component.html +++ b/webapp/src/app/home/leaderboard/leaderboard.component.html @@ -25,6 +25,13 @@ {{ entry.score }}
+
+ + {{ entry.numberOfReviewedPRs }} +
+
+ +
@if (entry.changesRequested && entry.changesRequested.length > 0) {
diff --git a/webapp/src/app/home/leaderboard/leaderboard.component.ts b/webapp/src/app/home/leaderboard/leaderboard.component.ts index 3feb3dc8..5a05d903 100644 --- a/webapp/src/app/home/leaderboard/leaderboard.component.ts +++ b/webapp/src/app/home/leaderboard/leaderboard.component.ts @@ -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'; @@ -37,6 +37,8 @@ export class LeaderboardComponent { protected octFileDiff = octFileDiff; protected octCheck = octCheck; protected octComment = octComment; + protected octGitPullRequest = octGitPullRequest; + protected octChevronRight = octChevronRight; leaderboard = input(); } From 02e00b8894253d75882ef796205b60745b801c0a Mon Sep 17 00:00:00 2001 From: GODrums Date: Wed, 25 Sep 2024 18:06:54 +0200 Subject: [PATCH 2/6] Add Number of Reviews --- server/application-server/openapi.yaml | 3 +++ .../in/www1/hephaestus/leaderboard/LeaderboardEntry.java | 1 + .../in/www1/hephaestus/leaderboard/LeaderboardService.java | 3 +++ .../src/app/core/modules/openapi/model/leaderboard-entry.ts | 1 + webapp/src/app/home/leaderboard/leaderboard.component.html | 6 +++++- webapp/src/app/home/leaderboard/leaderboard.component.ts | 3 ++- 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/server/application-server/openapi.yaml b/server/application-server/openapi.yaml index 1e0fb315..f5844f74 100644 --- a/server/application-server/openapi.yaml +++ b/server/application-server/openapi.yaml @@ -468,6 +468,9 @@ components: numberOfReviewedPRs: type: integer format: int32 + numberOfReviews: + type: integer + format: int32 changesRequested: type: array items: diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardEntry.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardEntry.java index a0dafb54..8ce067cc 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardEntry.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardEntry.java @@ -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; diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java index a031c407..5be7e4df 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java @@ -57,6 +57,7 @@ public List createLeaderboard(Optional after, Optio } AtomicInteger score = new AtomicInteger(0); Set reviewedPRs = new HashSet<>(); + AtomicInteger numberOfReviews = new AtomicInteger(0); Set changesRequestedSet = new HashSet<>(); Set approvedSet = new HashSet<>(); Set commentSet = new HashSet<>(); @@ -71,6 +72,7 @@ public List createLeaderboard(Optional after, Optio review.getUpdatedAt(), review.getSubmittedAt(), review.getState()); reviewedPRs.add(review.getPullRequest().getNumber()); + numberOfReviews.incrementAndGet(); switch (review.getState()) { case CHANGES_REQUESTED: changesRequestedSet.add(reviewDTO); @@ -91,6 +93,7 @@ public List createLeaderboard(Optional 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()])); diff --git a/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts b/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts index e65a9c77..89008e67 100644 --- a/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts +++ b/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts @@ -20,6 +20,7 @@ export interface LeaderboardEntry { score?: number; rank?: number; numberOfReviewedPRs?: number; + numberOfReviews?: number; changesRequested?: Array; approvals?: Array; comments?: Array; diff --git a/webapp/src/app/home/leaderboard/leaderboard.component.html b/webapp/src/app/home/leaderboard/leaderboard.component.html index 59cd9368..cc606655 100644 --- a/webapp/src/app/home/leaderboard/leaderboard.component.html +++ b/webapp/src/app/home/leaderboard/leaderboard.component.html @@ -25,7 +25,11 @@ {{ entry.score }}
-
+
+ + {{ entry.numberOfReviews }} +
+
{{ entry.numberOfReviewedPRs }}
diff --git a/webapp/src/app/home/leaderboard/leaderboard.component.ts b/webapp/src/app/home/leaderboard/leaderboard.component.ts index 5a05d903..6bed9fd9 100644 --- a/webapp/src/app/home/leaderboard/leaderboard.component.ts +++ b/webapp/src/app/home/leaderboard/leaderboard.component.ts @@ -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'; @@ -39,6 +39,7 @@ export class LeaderboardComponent { protected octComment = octComment; protected octGitPullRequest = octGitPullRequest; protected octChevronRight = octChevronRight; + protected octEye = octEye; leaderboard = input(); } From d9f14d6df6864406c99df7bba170203800036264 Mon Sep 17 00:00:00 2001 From: GODrums Date: Sun, 29 Sep 2024 20:52:05 +0200 Subject: [PATCH 3/6] remove review counter --- .../in/www1/hephaestus/leaderboard/LeaderboardService.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java index 5be7e4df..6c62037b 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java @@ -57,7 +57,6 @@ public List createLeaderboard(Optional after, Optio } AtomicInteger score = new AtomicInteger(0); Set reviewedPRs = new HashSet<>(); - AtomicInteger numberOfReviews = new AtomicInteger(0); Set changesRequestedSet = new HashSet<>(); Set approvedSet = new HashSet<>(); Set commentSet = new HashSet<>(); @@ -72,7 +71,6 @@ public List createLeaderboard(Optional after, Optio review.getUpdatedAt(), review.getSubmittedAt(), review.getState()); reviewedPRs.add(review.getPullRequest().getNumber()); - numberOfReviews.incrementAndGet(); switch (review.getState()) { case CHANGES_REQUESTED: changesRequestedSet.add(reviewDTO); @@ -93,7 +91,7 @@ public List createLeaderboard(Optional after, Optio score.get(), 0, // preliminary rank reviewedPRs.size(), - numberOfReviews.get(), + user.getReviews().size(), changesRequestedSet.toArray(new PullRequestReviewDTO[changesRequestedSet.size()]), approvedSet.toArray(new PullRequestReviewDTO[approvedSet.size()]), commentSet.toArray(new PullRequestReviewDTO[commentSet.size()])); From b896ad7fbada044c45700322d30fa8d66d02ef4c Mon Sep 17 00:00:00 2001 From: Armin Stanitzok Date: Tue, 1 Oct 2024 14:35:41 +0200 Subject: [PATCH 4/6] Remove PR count --- server/application-server/openapi.yaml | 3 --- .../in/www1/hephaestus/leaderboard/LeaderboardEntry.java | 1 - .../in/www1/hephaestus/leaderboard/LeaderboardService.java | 1 - webapp/src/app/home/leaderboard/leaderboard.component.html | 6 +----- webapp/src/app/home/leaderboard/leaderboard.component.ts | 5 ++--- 5 files changed, 3 insertions(+), 13 deletions(-) diff --git a/server/application-server/openapi.yaml b/server/application-server/openapi.yaml index 8c905b42..48453c67 100644 --- a/server/application-server/openapi.yaml +++ b/server/application-server/openapi.yaml @@ -480,9 +480,6 @@ components: numberOfReviewedPRs: type: integer format: int32 - numberOfReviews: - type: integer - format: int32 changesRequested: type: array items: diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardEntry.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardEntry.java index 8ce067cc..a0dafb54 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardEntry.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardEntry.java @@ -22,7 +22,6 @@ public class LeaderboardEntry { private int score; private int rank; private int numberOfReviewedPRs; - private int numberOfReviews; private PullRequestReviewDTO[] changesRequested; private PullRequestReviewDTO[] approvals; private PullRequestReviewDTO[] comments; diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java index 6c62037b..a031c407 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/leaderboard/LeaderboardService.java @@ -91,7 +91,6 @@ public List createLeaderboard(Optional after, Optio score.get(), 0, // preliminary rank reviewedPRs.size(), - user.getReviews().size(), changesRequestedSet.toArray(new PullRequestReviewDTO[changesRequestedSet.size()]), approvedSet.toArray(new PullRequestReviewDTO[approvedSet.size()]), commentSet.toArray(new PullRequestReviewDTO[commentSet.size()])); diff --git a/webapp/src/app/home/leaderboard/leaderboard.component.html b/webapp/src/app/home/leaderboard/leaderboard.component.html index cc606655..a0979695 100644 --- a/webapp/src/app/home/leaderboard/leaderboard.component.html +++ b/webapp/src/app/home/leaderboard/leaderboard.component.html @@ -25,16 +25,12 @@ {{ entry.score }}
-
- - {{ entry.numberOfReviews }} -
{{ entry.numberOfReviewedPRs }}
- +
@if (entry.changesRequested && entry.changesRequested.length > 0) {
diff --git a/webapp/src/app/home/leaderboard/leaderboard.component.ts b/webapp/src/app/home/leaderboard/leaderboard.component.ts index 6bed9fd9..53fb04a7 100644 --- a/webapp/src/app/home/leaderboard/leaderboard.component.ts +++ b/webapp/src/app/home/leaderboard/leaderboard.component.ts @@ -1,6 +1,6 @@ import { Component, input } from '@angular/core'; import { NgIconComponent } from '@ng-icons/core'; -import { octFileDiff, octCheck, octComment, octGitPullRequest, octChevronRight, octEye } from '@ng-icons/octicons'; +import { octFileDiff, octCheck, octComment, octGitPullRequest, octChevronLeft } 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'; @@ -38,8 +38,7 @@ export class LeaderboardComponent { protected octCheck = octCheck; protected octComment = octComment; protected octGitPullRequest = octGitPullRequest; - protected octChevronRight = octChevronRight; - protected octEye = octEye; + protected octChevronLeft = octChevronLeft; leaderboard = input(); } From b130c77e2ada42a8bd5f8d1e4bcc5f2c1bb6d175 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 1 Oct 2024 14:26:15 +0000 Subject: [PATCH 5/6] chore: update API specs and client --- webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts b/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts index 89008e67..e65a9c77 100644 --- a/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts +++ b/webapp/src/app/core/modules/openapi/model/leaderboard-entry.ts @@ -20,7 +20,6 @@ export interface LeaderboardEntry { score?: number; rank?: number; numberOfReviewedPRs?: number; - numberOfReviews?: number; changesRequested?: Array; approvals?: Array; comments?: Array; From b870a365b20ba4ebfedae67520edeaeb0829e5bc Mon Sep 17 00:00:00 2001 From: Armin Stanitzok Date: Tue, 1 Oct 2024 16:51:48 +0200 Subject: [PATCH 6/6] fix: spacing + color --- .../app/home/leaderboard/leaderboard.component.html | 4 ++-- .../src/app/home/leaderboard/leaderboard.stories.ts | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/webapp/src/app/home/leaderboard/leaderboard.component.html b/webapp/src/app/home/leaderboard/leaderboard.component.html index a0979695..20f41cff 100644 --- a/webapp/src/app/home/leaderboard/leaderboard.component.html +++ b/webapp/src/app/home/leaderboard/leaderboard.component.html @@ -24,12 +24,12 @@ {{ entry.score }} -
+
{{ entry.numberOfReviewedPRs }}
-
+
@if (entry.changesRequested && entry.changesRequested.length > 0) { diff --git a/webapp/src/app/home/leaderboard/leaderboard.stories.ts b/webapp/src/app/home/leaderboard/leaderboard.stories.ts index 9432bb67..529cc2b7 100644 --- a/webapp/src/app/home/leaderboard/leaderboard.stories.ts +++ b/webapp/src/app/home/leaderboard/leaderboard.stories.ts @@ -25,7 +25,8 @@ const leaderboardEntries: LeaderboardEntry[] = [ changesRequested: generateReviews(3, PullRequestReviewDTO.StateEnum.ChangesRequested), approvals: generateReviews(5, PullRequestReviewDTO.StateEnum.Approved), comments: generateReviews(1, PullRequestReviewDTO.StateEnum.Commented), - rank: 1 + rank: 1, + numberOfReviewedPRs: 10 }, { githubName: 'FelixTJDietrich', @@ -36,7 +37,8 @@ const leaderboardEntries: LeaderboardEntry[] = [ changesRequested: generateReviews(1, PullRequestReviewDTO.StateEnum.ChangesRequested), approvals: generateReviews(1, PullRequestReviewDTO.StateEnum.Approved), comments: generateReviews(14, PullRequestReviewDTO.StateEnum.Commented), - rank: 2 + rank: 2, + numberOfReviewedPRs: 16 }, { githubName: 'krusche', @@ -47,7 +49,8 @@ const leaderboardEntries: LeaderboardEntry[] = [ changesRequested: [], approvals: generateReviews(3, PullRequestReviewDTO.StateEnum.Approved), comments: generateReviews(1, PullRequestReviewDTO.StateEnum.Commented), - rank: 3 + rank: 3, + numberOfReviewedPRs: 3 }, { githubName: 'shadcn', @@ -58,7 +61,8 @@ const leaderboardEntries: LeaderboardEntry[] = [ changesRequested: [], approvals: [], comments: generateReviews(1, PullRequestReviewDTO.StateEnum.Commented), - rank: 4 + rank: 4, + numberOfReviewedPRs: 1 } ];