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

Refactoring leaderboard #736

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions packages/app/src/app/contributors/_components/ContributorsList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Contributor from "./contributor"
import { GitHubContributor, contributors } from "../_helpers/types"
interface contributerListProps {
contributors: contributors;
sliceStartIndex: number;
sliceEndIndex: number;
contributorCommitActivities: any;
}
const Contributors = ({contributors,sliceStartIndex,sliceEndIndex,contributorCommitActivities}:contributerListProps) => {
return (
<div>
<ul className="grid gap-4 mt-8 list-none md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
{contributors
.slice(sliceStartIndex, sliceEndIndex)
.map((contributor: GitHubContributor) => (
<Contributor
key={contributor.id}
contributor={contributor}
contributorsCodeChanges={
contributorCommitActivities.find(
(e: { login: string }) => e.login === contributor.login,
) ?? { additions: 0, deletions: 0, login: contributor.login }
}
/>
))}
</ul>
</div>
)
}

export default Contributors
26 changes: 26 additions & 0 deletions packages/app/src/app/contributors/_helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,31 @@ interface GitHubContributorCommitActivity {
}[];
}


type contributors ={

login: string;
id: number;
node_id: string;
avatar_url: string;
gravatar_id: string;
url: string;
html_url: string;
followers_url: string;
following_url: string;
gists_url: string;
starred_url: string;
subscriptions_url: string;
organizations_url: string;
repos_url: string;
events_url: string;
received_events_url: string;
type: string;
site_admin: boolean;
contributions: number;

}[]

// GitHub API Response schemas ------------------------------------------

export {
Expand All @@ -67,4 +92,5 @@ export {
type GitHubContributor,
type GitHubCommit,
type ContributorCodeChanges,
type contributors,
};
24 changes: 7 additions & 17 deletions packages/app/src/app/contributors/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Heading } from "@/components/ui/heading";
import Contributor from "./_components/contributor";
import AdditionsDeletions from "./_components/additions-deletions";
import ProportionBarChart from "./_components/proportion-bar-chart";
import Time from "@/components/ui/time";
Expand All @@ -13,6 +12,7 @@ import {
getRepoWeeklyCodeChanges,
} from "./_helpers/utils";
import { redirect } from "next/navigation";
import ContributorsList from "./_components/ContributorsList";

const PER_PAGE_MAX = 12; // Limit to only 12 per page to avoid hitting rate limit

Expand Down Expand Up @@ -107,22 +107,12 @@ export default async function ContributorsPage({
/>
</div>
</div>
<ul className="grid gap-4 mt-8 list-none md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
{contributors
.slice(sliceStartIndex, sliceEndIndex)
.map((contributor) => (
<Contributor
key={contributor.id}
contributor={contributor}
contributorsCodeChanges={
contributorCommitActivities.find(
(e) => e.login === contributor.login,
) ?? { additions: 0, deletions: 0, login: contributor.login }
}
/>
))}
</ul>

<ContributorsList
contributors={contributors}
sliceStartIndex={sliceStartIndex}
sliceEndIndex={sliceEndIndex}
contributorCommitActivities={contributorCommitActivities}
></ContributorsList>
<PaginationBar
className="flex justify-center w-full mt-6"
nextURL={`/contributors?page=${Math.min(
Expand Down
9 changes: 4 additions & 5 deletions packages/app/src/app/terms/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ const page = () => {
<>
<Heading title="Terms" />
<div>
<h1>CodeRacer - Terms of Service</h1>
<p><strong>Effective Date:</strong> [Date]</p>

<p>Welcome to CodeRacer! These Terms of Service ("Terms") constitute a legal agreement between you and CodeRacer. Please read these Terms carefully before using our platform, which is accessible at <a href="https://code-racer-eight.vercel.app/">https://code-racer-eight.vercel.app/</a>. By using CodeRacer, you agree to be bound by these Terms.</p>
<h1>CodeRacer - Terms of Service</h1>
<p>Welcome to CodeRacer! These Terms of Service Terms constitute a legal agreement between you and CodeRacer. Please read these Terms carefully before using our platform, which is accessible at <a href="https://code-racer-eight.vercel.app/">https://code-racer-eight.vercel.app/</a>. By using CodeRacer, you agree to be bound by these Terms.</p>

<h2>1. User Accounts</h2>
<p>
Expand Down Expand Up @@ -45,7 +43,7 @@ const page = () => {

<h2>6. Limitation of Liability</h2>
<p>
<strong>6.1. Disclaimer:</strong> CodeRacer is provided "as is," and we make no warranties or representations about the accuracy or reliability of the platform. Your use of CodeRacer is at your own risk.
<strong>6.1. Disclaimer:</strong> CodeRacer is provided as is, and we make no warranties or representations about the accuracy or reliability of the platform. Your use of CodeRacer is at your own risk.
</p>

<h2>7. Changes to Terms</h2>
Expand All @@ -58,6 +56,7 @@ const page = () => {
<strong>8.1. Questions:</strong> If you have any questions or concerns about these Terms, please contact us at <a href="mailto:[email protected]">[email protected]</a>.
</p>
</div>
</>
);
};

Expand Down