Skip to content

Commit

Permalink
Merge pull request #16 from namidapoo/dev
Browse files Browse the repository at this point in the history
Release `v1.0.1`
  • Loading branch information
namidapoo authored Dec 29, 2024
2 parents 1c906f4 + bce45f2 commit 2c8dd72
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 27 deletions.
Binary file modified app/favicon.ico
Binary file not shown.
5 changes: 3 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export default async function Home() {
const session = await auth();
if (!session?.user) return null;

console.log(session);

return (
<div className="grid grid-cols-1 md:grid-cols-3 gap-8 h-full pt-24 px-4 text-accent-foreground md:items-center justify-items-center">
<div className="col-span-1 w-full max-w-md space-y-8 text-center">
Expand Down Expand Up @@ -49,13 +47,15 @@ export default async function Home() {
width={20}
height={20}
className="dark:hidden"
priority
/>
<Image
src={GitHubBlack}
alt="GitHub"
width={20}
height={20}
className="hidden dark:block"
priority
/>
振り返りを見る
</Link>
Expand All @@ -69,6 +69,7 @@ export default async function Home() {
width={700}
height={800}
className="w-full h-auto mx-auto rounded-md"
priority
/>
</div>
</div>
Expand Down
28 changes: 28 additions & 0 deletions app/recap/components/calculate-change-rate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* 去年の数値(prevYear) と 今年の数値(currentYear)を引数に取り、
* 数値(小数第2位まで) か "-" を返す関数
*
* @param {number} prevYear - 去年のコミット数や指標となる数値
* @param {number} currentYear - 今年のコミット数や指標となる数値
* @returns {number|"-"} - 有効な場合は数値型、無効の場合は "-"
*/
export function calculateChangeRate(
prevYear: number,
currentYear: number,
): number | "-" {
if (typeof prevYear !== "number" || typeof currentYear !== "number") {
return "-";
}

if (prevYear === 0) {
return "-";
}

const ratio = ((currentYear - prevYear) / prevYear) * 100;

if (!Number.isFinite(ratio)) {
return "-";
}

return Number.parseFloat(ratio.toFixed(2));
}
41 changes: 17 additions & 24 deletions app/recap/components/overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
UsersRound,
} from "lucide-react";
import type { FC } from "react";
import { calculateChangeRate } from "./calculate-change-rate";
import { LanguagesUsageGraph } from "./graph/languages";
import { MonthlyContributionsGraph } from "./graph/monthly";
import { WeeklyContributionsGraph } from "./graph/weekly";
Expand Down Expand Up @@ -98,12 +99,10 @@ export const OverView: FC<Props> = async ({ data }) => {
<p className="text-xs text-muted-foreground">
前年と比較して
<b>
{(
((data.totalCommitCount -
data.previousYearStats.totalCommitCount) /
data.previousYearStats.totalCommitCount) *
100
).toFixed(2)}
{calculateChangeRate(
data.previousYearStats.totalCommitCount,
data.totalCommitCount,
)}
</b>
% 増加しました。
</p>
Expand All @@ -123,12 +122,10 @@ export const OverView: FC<Props> = async ({ data }) => {
<p className="text-xs text-muted-foreground">
前年と比較して
<b>
{(
((data.closedIssuesAssigned -
data.previousYearStats.closedIssuesAssignedCount) /
data.previousYearStats.closedIssuesAssignedCount) *
100
).toFixed(2)}
{calculateChangeRate(
data.previousYearStats.closedIssuesAssignedCount,
data.closedIssuesAssigned,
)}
</b>
% 増加しました。
</p>
Expand All @@ -148,12 +145,10 @@ export const OverView: FC<Props> = async ({ data }) => {
<p className="text-xs text-muted-foreground">
前年と比較して
<b>
{(
((data.openedPullRequests -
data.previousYearStats.openedPullRequests) /
data.previousYearStats.openedPullRequests) *
100
).toFixed(2)}
{calculateChangeRate(
data.previousYearStats.openedPullRequests,
data.openedPullRequests,
)}
</b>
% 増加しました。
</p>
Expand All @@ -173,12 +168,10 @@ export const OverView: FC<Props> = async ({ data }) => {
<p className="text-xs text-muted-foreground">
前年と比較して
<b>
{(
((data.reviewedPullRequests -
data.previousYearStats.reviewedPullRequests) /
data.previousYearStats.reviewedPullRequests) *
100
).toFixed(2)}
{calculateChangeRate(
data.previousYearStats.reviewedPullRequests,
data.reviewedPullRequests,
)}
</b>
% 増加しました。
</p>
Expand Down
2 changes: 1 addition & 1 deletion lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
GitHub({
authorization: {
param: {
scope: "repo read:user",
scope: "repo",
},
},
}),
Expand Down

0 comments on commit 2c8dd72

Please sign in to comment.