From 71ebe210439c50649c45cda4f73c56c0bb93f6bf Mon Sep 17 00:00:00 2001 From: Krishnavamsi-codes Date: Thu, 28 May 2026 13:53:31 +0530 Subject: [PATCH 1/2] Integrated analytics dashboard into tracker workflow --- src/pages/Tracker/Tracker.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pages/Tracker/Tracker.tsx b/src/pages/Tracker/Tracker.tsx index 576f39bf..ad92b613 100644 --- a/src/pages/Tracker/Tracker.tsx +++ b/src/pages/Tracker/Tracker.tsx @@ -33,6 +33,8 @@ import { useTheme } from "@mui/material/styles"; import { useGitHubAuth } from "../../hooks/useGitHubAuth"; import { useGitHubData } from "../../hooks/useGitHubData"; import { KeyIcon } from "lucide-react"; +import Dashboard from "../../components/Dashboard"; + const ROWS_PER_PAGE = 10; @@ -335,7 +337,14 @@ const Home: React.FC = () => { ) : ( - + <> + + @@ -395,6 +404,7 @@ const Home: React.FC = () => { + )} ); From d02e091288932025b97a43ae4081f764c6a7a0aa Mon Sep 17 00:00:00 2001 From: Krishnavamsi-codes Date: Thu, 28 May 2026 16:45:40 +0530 Subject: [PATCH 2/2] Fixed dashboard analytics scope consistency --- backend/server.js | 2 +- src/components/Dashboard.tsx | 41 ++++++++++++++++++++++++----------- src/pages/Tracker/Tracker.tsx | 4 +--- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/backend/server.js b/backend/server.js index 48d6ccfb..e760ce10 100644 --- a/backend/server.js +++ b/backend/server.js @@ -19,7 +19,7 @@ app.use(cors({ origin: function (origin, callback) { if (!origin || allowedOrigins.indexOf(origin) !== -1) { callback(null, true); - } else{ + } else { callback(new Error('Blocked by CORS policy')); } }, diff --git a/src/components/Dashboard.tsx b/src/components/Dashboard.tsx index e28358f0..91581cdf 100644 --- a/src/components/Dashboard.tsx +++ b/src/components/Dashboard.tsx @@ -25,22 +25,37 @@ interface GitHubItem { } interface DashboardProps { - totalIssues: number; - totalPrs: number; data: GitHubItem[]; theme: Theme; } -const Dashboard: React.FC = ({ totalIssues, totalPrs, data, theme }) => { +const Dashboard: React.FC = ({ data, theme }) => { + // Count states for state distribution chart + const openCount = data.filter( + item => item.state === 'open' + ).length; + + const mergedCount = data.filter( + item => !!item.pull_request?.merged_at + ).length; + + const closedCount = data.filter( + item => item.state === 'closed' && !item.pull_request?.merged_at + ).length; + // Data for Pie Chart const pieData = [ - { name: 'Issues', value: totalIssues }, - { name: 'Pull Requests', value: totalPrs }, + { name: 'Open', value: openCount, color: theme.palette.success.main }, + { name: 'Closed', value: closedCount, color: theme.palette.error.main }, ]; - // Use theme-aware colors - const COLORS = [theme.palette.primary.main, theme.palette.secondary.main]; + if (mergedCount > 0) { + pieData.push({ name: 'Merged', value: mergedCount, color: theme.palette.secondary.main }); + } + + // Filter out states with zero counts to avoid empty chart slices/labels + const activePieData = pieData.filter(d => d.value > 0); // Data for Bar Chart (Top 5 Repositories) - Improved safety const repoCounts: { [key: string]: number } = {}; @@ -62,7 +77,7 @@ const Dashboard: React.FC = ({ totalIssues, totalPrs, data, them .sort((a, b) => b.count - a.count) .slice(0, 5); - const hasData = totalIssues > 0 || totalPrs > 0; + const hasData = data.length > 0; if (!hasData) { return ( @@ -81,12 +96,12 @@ const Dashboard: React.FC = ({ totalIssues, totalPrs, data, them - Contribution Mix (Total) + State Distribution (Filtered Results) = ({ totalIssues, totalPrs, data, them dataKey="value" label > - {pieData.map((_entry, index) => ( - + {activePieData.map((entry, index) => ( + ))} = ({ totalIssues, totalPrs, data, them - Top Repositories (Current View) + Top Repositories (Filtered Results) {barData.length > 0 ? ( diff --git a/src/pages/Tracker/Tracker.tsx b/src/pages/Tracker/Tracker.tsx index ad92b613..f1aaf31e 100644 --- a/src/pages/Tracker/Tracker.tsx +++ b/src/pages/Tracker/Tracker.tsx @@ -339,9 +339,7 @@ const Home: React.FC = () => { ) : ( <>