Skip to content

Commit

Permalink
#144: update dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
iam-flo committed Dec 2, 2024
1 parent e0b8d22 commit 26462ca
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.util.List;
import java.util.Set;
import java.util.stream.Stream;

@Service
public class ActivityService {
Expand Down Expand Up @@ -51,17 +52,14 @@ public ActivityDTO getActivity(String login) {
}

private List<ReviewActivityDTO> getReviewedOrRequestedPullRequests(String login) {
List<ReviewActivityDTO> reviews = pullRequestReviewRepository.findAllOpenReviewsByAuthorLogin(login)
Stream<ReviewActivityDTO> reviews = pullRequestReviewRepository.findAllOpenReviewsByAuthorLogin(login)
.stream()
.map(ReviewActivityDTO::fromPullRequestReview)
.toList();
.map(ReviewActivityDTO::fromPullRequestReview);

List<ReviewActivityDTO> requestedReviews = pullRequestRepository.findReviewRequestedByLogin(login)
Stream<ReviewActivityDTO> requestedReviews = pullRequestRepository.findOpenReviewRequestedByLogin(login)
.stream()
.map(ReviewActivityDTO::fromPullRequest)
.toList();
.map(ReviewActivityDTO::fromPullRequest);

requestedReviews.addAll(reviews);
return requestedReviews;
return Stream.concat(reviews, requestedReviews).toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ WHERE Type(p) = PullRequest
JOIN FETCH p.author
LEFT JOIN FETCH p.assignees
LEFT JOIN FETCH p.repository
WHERE LOWER(:reviewerLogin) IN (SELECT LOWER(u.login) FROM p.requestedReviewers u)
WHERE LOWER(:reviewerLogin) IN (SELECT LOWER(u.login) FROM p.requestedReviewers u) and p.state = 'OPEN'
ORDER BY p.createdAt DESC
""")
List<PullRequest> findReviewRequestedByLogin(@Param("reviewerLogin") String reviewerLogin);
List<PullRequest> findOpenReviewRequestedByLogin(@Param("reviewerLogin") String reviewerLogin);
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,7 @@ List<PullRequestReview> findAllInTimeframeOfTeam(
LEFT JOIN FETCH prr.pullRequest.repository
LEFT JOIN FETCH prr.comments
WHERE prr.author.login ILIKE :authorLogin AND prr.pullRequest.state = 'OPEN'
AND prr.submittedAt = (
SELECT MAX(subPrr.submittedAt)
FROM PullRequestReview subPrr
WHERE subPrr.pullRequest.id = prr.pullRequest.id
)
ORDER BY prr.submittedAt DESC
""")
List<PullRequestReview> findAllOpenReviewsByAuthorLogin(@Param("authorLogin") String authorLogin);

}
5 changes: 2 additions & 3 deletions webapp/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const routes: Routes = [
{ path: 'settings', component: SettingsComponent },
{ path: 'imprint', component: ImprintComponent },
{ path: 'privacy', component: PrivacyComponent },
{ path: 'activity/:id', component: ActivityDashboardComponent },

// Protected routes
{
Expand All @@ -50,7 +51,5 @@ export const routes: Routes = [
{ path: 'settings', component: SettingsComponent },
{ path: 'workspace', component: WorkspaceComponent, canActivate: [AdminGuard] }
]
},
{ path: 'user/:id', component: UserProfileComponent },
{ path: 'activity/:id', component: ActivityDashboardComponent }
}
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<div class="flex flex-col gap-8">
<div>
<p class="text-xl font-semibold">Open pull requests</p>
<div class="flex flex-row justify-between pt-2 w-full">
<div class="flex flex-col w-1/2 gap-2 m-1 mr-3">
@if (query.data()?.pullRequests) {
@for (activity of query.data()?.pullRequests; track activity.id) {
<app-issue-card
class="w-full"
[title]="activity.title"
[number]="activity.number"
[additions]="activity.additions"
[deletions]="activity.deletions"
[htmlUrl]="activity.htmlUrl"
[repositoryName]="activity.repository?.name"
[createdAt]="activity.createdAt"
[state]="activity.state"
[isDraft]="activity.isDraft"
[isMerged]="activity.isMerged"
[pullRequestLabels]="activity.labels"
>
</app-issue-card>
}
}
</div>
<div class="border-l mx-4 border-border"></div>
<div class="w-1/2">
<p>Pull request metrics coming</p>
</div>
</div>
</div>

<div>
<p class="text-xl font-semibold">Open issues</p>
<div class="flex flex-row justify-between pt-2 w-full">
<div class="flex flex-col w-1/2 gap-2 m-1 mr-3">
@if (query.data()?.issues) {
@for (issue of query.data()?.issues; track issue.id) {
<app-issue-card
class="w-full"
[title]="issue.title"
[number]="issue.number"
[htmlUrl]="issue.htmlUrl"
[repositoryName]="issue.repositoryNameWithOwner"
[createdAt]="issue.createdAt"
[state]="issue.state"
[isIssue]="true"
>
</app-issue-card>
}
}
</div>
<div class="border-l mx-4 border-border"></div>
<div class="w-1/2">
<p>Issue metrics coming</p>
</div>
</div>

<div>
<p class="text-xl font-semibold">Open reviews</p>
<div class="flex flex-row justify-between pt-2 w-full">
<div class="flex flex-col w-1/2 gap-2 m-1 mr-3">
@if (query.data()?.reviews) {
@for (review of query.data()?.reviews; track review.id) {
<app-issue-card
class="w-full"
[title]="review.pullRequest?.title"
[number]="review.pullRequest?.number"
[htmlUrl]="review.pullRequest?.htmlUrl"
[repositoryName]="review.pullRequest?.repository?.name"
[state]="review.pullRequest?.state"
[isDraft]="review.pullRequest?.isDraft"
[isMerged]="review.pullRequest?.isMerged"
[additions]="review.pullRequest?.additions"
[deletions]="review.pullRequest?.deletions"
>
</app-issue-card>
}
}
</div>
<div class="border-l mx-4 border-border"></div>
<div class="w-1/2">
<p>Review metrics coming</p>
</div>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Component, inject } from '@angular/core';
import { ActivityService } from '@app/core/modules/openapi';
import { injectQuery } from '@tanstack/angular-query-experimental';
import { combineLatest, lastValueFrom, map, timer } from 'rxjs';
import { ActivatedRoute } from '@angular/router';
import { IssueCardComponent } from '@app/user/issue-card/issue-card.component';

@Component({
selector: 'app-activity-dashboard',
standalone: true,
imports: [IssueCardComponent],
templateUrl: './activity-dashboard.component.html',
styles: ``
})
export class ActivityDashboardComponent {
activityService = inject(ActivityService);

protected userLogin: string | null = null;

constructor(private route: ActivatedRoute) {
this.userLogin = this.route.snapshot.paramMap.get('id');
}

query = injectQuery(() => ({
queryKey: ['user', { id: this.userLogin }],
enabled: !!this.userLogin,
queryFn: async () => lastValueFrom(combineLatest([this.activityService.getActivityByUser(this.userLogin!), timer(400)]).pipe(map(([activity]) => activity)))
}));
}

0 comments on commit 26462ca

Please sign in to comment.