Skip to content

Commit

Permalink
FEAT: added the pull request analysis counter
Browse files Browse the repository at this point in the history
  • Loading branch information
SANKALP1011 committed Feb 8, 2024
1 parent 6a57a3e commit bad8e0f
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 3 deletions.
45 changes: 45 additions & 0 deletions src/Components/PullReqAnalysis/PullReqProgress.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, { useState } from "react";
import { DonutChart, Card, Title } from "@tremor/react";
import { PullRequestAnalysis } from "@/Interface/api.interface";
import { RoughNotation } from "react-rough-notation";

const PullRequestProgress: React.FC<PullRequestAnalysis> = ({
OpenCount,
ClosedCount,
}) => {
const valueFormatter = (value: number) => `${value}%`;
const [show, setShow] = useState(true);

const openCount = typeof OpenCount === "number" ? OpenCount : 0;
const closedCount = typeof ClosedCount === "number" ? ClosedCount : 0;

const chartData = [
{ name: "Open Count", value: openCount },
{ name: "Closed Count", value: closedCount },
];

return (
<div className="pullRequestCard relative group items-start justify-center ml-16">
<div className="pullReqGradientBack w-full absolute -inset-0.5 bg-gradient-to-r from-purple-600 to-indigo-600 blur opacity-75 group-hover:opacity-100 transition duration-1000 group-hover:duration-500 animate-pulse"></div>
<Card className="pullRequestCard">
<RoughNotation type="underline" show={show} color="green" strokeWidth={5}>
{" "}
<Title className="pullRequestTitle font-mono">
Pull Request Analysis
</Title>
</RoughNotation>

<DonutChart
className="mt-4 h-28"
data={chartData}
category="value"
index="name"
valueFormatter={valueFormatter}
colors={["rose", "yellow"]}
/>
</Card>
</div>
);
};

export default PullRequestProgress;
5 changes: 5 additions & 0 deletions src/Interface/api.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ export interface FollowerFollowingRatio {
export interface RepoCountAnalysis{
RepoCount: number;
increaseOrDecrease:string
}

export interface PullRequestAnalysis{
OpenCount: number;
ClosedCount: number;
}
17 changes: 16 additions & 1 deletion src/Styles/Dashboard/followerProgress.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,22 @@
margin-left: 10%;
border-radius: 30px;
}

.pullRequestCard{
background-color: black;
border-radius: 55px;
text-align: center;
max-width: 250px;
height: 200px;
}
.pullReqGradientBack{
height: 210px;
border-radius: 30px;
}
.pullRequestTitle{
color: white;
font-size: 15px;
font-weight: bolder;
}



Expand Down
31 changes: 31 additions & 0 deletions src/app/Dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ import {
getFollowingAnalysis,
getLanguageCountAnalysis,
getRepoCountAnalysis,
getOpenCount,
getClosedCount
} from "@/Services/analysis.service";
import {
FollowerAnalysis,
FollowingAnalysis,
LanguageCountAnalysis,
RepoCountAnalysis,
PullRequestAnalysis
} from "@/Interface/api.interface";
import FollowerProgress from "@/Components/FollowerAnalysis/FollowerProgress";
import FollowingProgress from "@/Components/FollowerAnalysis/FollowingProgress";
import LanguageCount from "@/Components/LanguageAnalysis/LanguageCount";
import RepoProgress from "@/Components/Repository/RepoProgress";
import PullRequestProgress from "@/Components/PullReqAnalysis/PullReqProgress";


const VersionDashboard: React.FC = () => {
Expand All @@ -48,6 +52,9 @@ const VersionDashboard: React.FC = () => {
increaseOrDecrease: "",
});

const [issueCount,setIssueCount] = useState<PullRequestAnalysis>({OpenCount:0,ClosedCount:0});


const getFollowerAnalysisData = async () => {
try {
const response: any = await getFollowerAnalysis(
Expand Down Expand Up @@ -95,12 +102,35 @@ const VersionDashboard: React.FC = () => {
console.error("Error fetching language count analysis:", error);
}
};
const getIssueCounts = async () => {
try {
const [openResponse, closedResponse]:[any,any] = await Promise.all([
getOpenCount("64b2e27fd3b241f53c4b4c55"),
getClosedCount("64b2e27fd3b241f53c4b4c55")
]);

const openCountData: { OpenCount: number } = await openResponse.json();
const closedCountData: { ClosedCount: number } = await closedResponse.json();

console.log("here is the main data")
console.log(openCountData)

setIssueCount({ OpenCount: openCountData.OpenCount, ClosedCount: closedCountData.ClosedCount });
} catch (err) {
console.error("Error fetching issue counts:", err);
}
};





useEffect(() => {
getFollowerAnalysisData();
getFollowingAnalysisData();
getLanguageCountAnalysisData();
getRepoCountAnalysisData();
getIssueCounts()
}, []);

return followerAnlData.followerCount !== 0 &&
Expand Down Expand Up @@ -159,6 +189,7 @@ const VersionDashboard: React.FC = () => {
<div className="langCountCardContainer drop-shadow-2xl">
<LanguageCount languageCounts={langCount} />
</div>
<PullRequestProgress OpenCount={issueCount.OpenCount} ClosedCount={issueCount.ClosedCount}/>
</div>
</div>
) : (
Expand Down
4 changes: 2 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Image from "next/image";
import VersionDashboard from "./Dashboard/page";

import "../Styles/Dashboard/followerProgress.css"


export default function Home() {
return (
<h1>nkn</h1>

<VersionDashboard/>

);
}

0 comments on commit bad8e0f

Please sign in to comment.