Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
12 changes: 11 additions & 1 deletion components/top-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Props = {
export function TopList({ userResults }: Props) {
const cardDetails = (data: {
title: string;
url?: string;
subtitle?: string;
score?: number;
badges: { tooltip?: string; label?: any; icon: any }[];
Expand All @@ -37,7 +38,15 @@ export function TopList({ userResults }: Props) {
key={data.key}
>
<div>
<div className="font-medium text-slate-900">{data.title}</div>
<div className="font-medium text-slate-900">
{data.url ? (
<a href={data.url} target="_blank" rel="noopener noreferrer" className="hover:underline">
{data.title}
</a>
) : (
data.title
)}
</div>
<div className="text-xs text-muted-foreground mt-1">
{data.subtitle}
</div>
Expand Down Expand Up @@ -125,6 +134,7 @@ export function TopList({ userResults }: Props) {
cardDetails({
key: `pr-${i}`,
title: pr.title || "Untitled Pull Request",
url: pr.url,
subtitle: `in ${pr.repo}`,
score: pr.score,
badges: [
Expand Down
2 changes: 2 additions & 0 deletions lib/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const QUERY = /* GraphQL */ `
orderBy: { field: CREATED_AT, direction: DESC }
) {
nodes {
title
url
merged
additions
deletions
Expand Down
5 changes: 3 additions & 2 deletions lib/score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function calculateUserScore(
contributionScore: number;
finalScore: number;
topRepos: { name: string; stars: number; forks: number; score: number }[];
topPullRequests: { repo: string; stars: number; score: number }[];
topPullRequests: { repo: string; title: string; url: string; stars: number; score: number }[];
} {
const repoScore = calculateRepoScore(data.repos);
const prScore = calculatePRScore(data.pullRequests, username);
Expand All @@ -114,7 +114,8 @@ export function calculateUserScore(
})),
topPullRequests: prScore.details.slice(0, 3).map((item) => ({
repo: item.pr.repository.nameWithOwner,
title: item.pr.repository.nameWithOwner,
title: item.pr.title,
url: item.pr.url,
stars: item.pr.repository.stargazerCount,
score: item.score,
additions: item.pr.additions,
Expand Down
2 changes: 2 additions & 0 deletions types/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export type RepoNode = {
};

export type PullRequestNode = {
title: string;
url: string;
merged: boolean;
additions: number;
deletions: number;
Expand Down
1 change: 1 addition & 0 deletions types/user-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type UserResult = {
stars?: number;
score?: number;
title?: string;
url?: string;
deletions?: number;
additions?: number;
}[];
Expand Down
Loading