Skip to content

Commit

Permalink
fix leaderboard story
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixTJDietrich committed Sep 18, 2024
1 parent f8d3792 commit ee4d935
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
5 changes: 0 additions & 5 deletions webapp/src/app/home/leaderboard/leaderboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,4 @@ export class LeaderboardComponent {
protected octComment = octComment;

leaderboard = input<LeaderboardEntry[]>();

// run on leaderboard changes
ngOnChanges() {
console.log('Leaderboard changes: ', this.leaderboard());
}
}
37 changes: 25 additions & 12 deletions webapp/src/app/home/leaderboard/leaderboard.stories.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import { argsToTemplate, type Meta, type StoryObj } from '@storybook/angular';
import { LeaderboardComponent } from './leaderboard.component';
import { LeaderboardEntry } from 'app/core/modules/openapi/model/leaderboard-entry';
import { PullRequestReviewDTO } from 'app/core/modules/openapi/model/pull-request-review-dto';

let reviewIdCounter = 1;

const generateReviews = (count: number, state: PullRequestReviewDTO.StateEnum): PullRequestReviewDTO[] => {
return Array.from({ length: count }, () => ({
id: reviewIdCounter++,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
submittedAt: new Date().toISOString(),
state
}));
};

const leaderboardEntries: LeaderboardEntry[] = [
{
Expand All @@ -9,9 +22,9 @@ const leaderboardEntries: LeaderboardEntry[] = [
type: LeaderboardEntry.TypeEnum.User,
name: 'Armin Stanitzok',
score: 100,
changesRequested: 3,
approvals: 5,
comments: 1,
changesRequested: generateReviews(3, PullRequestReviewDTO.StateEnum.ChangesRequested),
approvals: generateReviews(5, PullRequestReviewDTO.StateEnum.Approved),
comments: generateReviews(1, PullRequestReviewDTO.StateEnum.Commented),
rank: 1
},
{
Expand All @@ -20,9 +33,9 @@ const leaderboardEntries: LeaderboardEntry[] = [
type: LeaderboardEntry.TypeEnum.User,
name: 'Felix T.J. Dietrich',
score: 90,
changesRequested: 1,
approvals: 1,
comments: 14,
changesRequested: generateReviews(1, PullRequestReviewDTO.StateEnum.ChangesRequested),
approvals: generateReviews(1, PullRequestReviewDTO.StateEnum.Approved),
comments: generateReviews(14, PullRequestReviewDTO.StateEnum.Commented),
rank: 2
},
{
Expand All @@ -31,9 +44,9 @@ const leaderboardEntries: LeaderboardEntry[] = [
type: LeaderboardEntry.TypeEnum.User,
name: 'Stephan Krusche',
score: 50,
changesRequested: 0,
approvals: 3,
comments: 1,
changesRequested: [],
approvals: generateReviews(3, PullRequestReviewDTO.StateEnum.Approved),
comments: generateReviews(1, PullRequestReviewDTO.StateEnum.Commented),
rank: 3
},
{
Expand All @@ -42,9 +55,9 @@ const leaderboardEntries: LeaderboardEntry[] = [
type: LeaderboardEntry.TypeEnum.User,
name: 'shadcn',
score: 20,
changesRequested: 0,
approvals: 0,
comments: 1,
changesRequested: [],
approvals: [],
comments: generateReviews(1, PullRequestReviewDTO.StateEnum.Commented),
rank: 4
}
];
Expand Down

0 comments on commit ee4d935

Please sign in to comment.