Skip to content
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
2 changes: 1 addition & 1 deletion backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
},
Expand Down
41 changes: 28 additions & 13 deletions src/components/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,37 @@ interface GitHubItem {
}

interface DashboardProps {
totalIssues: number;
totalPrs: number;
data: GitHubItem[];
theme: Theme;
}

const Dashboard: React.FC<DashboardProps> = ({ totalIssues, totalPrs, data, theme }) => {
const Dashboard: React.FC<DashboardProps> = ({ 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 } = {};
Expand All @@ -62,7 +77,7 @@ const Dashboard: React.FC<DashboardProps> = ({ 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 (
Expand All @@ -81,12 +96,12 @@ const Dashboard: React.FC<DashboardProps> = ({ totalIssues, totalPrs, data, them
<Grid item xs={12} md={6}>
<Paper elevation={2} sx={{ p: 2, height: 350, backgroundColor: theme.palette.background.paper }}>
<Typography variant="h6" gutterBottom align="center" color="textPrimary">
Contribution Mix (Total)
State Distribution (Filtered Results)
</Typography>
<ResponsiveContainer width="100%" height="90%">
<PieChart>
<Pie
data={pieData}
data={activePieData}
cx="50%"
cy="50%"
innerRadius={60}
Expand All @@ -96,8 +111,8 @@ const Dashboard: React.FC<DashboardProps> = ({ totalIssues, totalPrs, data, them
dataKey="value"
label
>
{pieData.map((_entry, index) => (
<Cell key={`cell-${index}`} fill={COLORS[index % COLORS.length]} />
{activePieData.map((entry, index) => (
<Cell key={`cell-${index}`} fill={entry.color} />
))}
</Pie>
<Tooltip
Expand All @@ -113,7 +128,7 @@ const Dashboard: React.FC<DashboardProps> = ({ totalIssues, totalPrs, data, them
<Grid item xs={12} md={6}>
<Paper elevation={2} sx={{ p: 2, height: 350, backgroundColor: theme.palette.background.paper }}>
<Typography variant="h6" gutterBottom align="center" color="textPrimary">
Top Repositories (Current View)
Top Repositories (Filtered Results)
</Typography>
{barData.length > 0 ? (
<ResponsiveContainer width="100%" height="90%">
Expand Down
10 changes: 9 additions & 1 deletion src/pages/Tracker/Tracker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -335,7 +337,12 @@ const Home: React.FC = () => {
<CircularProgress />
</Box>
) : (
<Box sx={{ maxHeight: "400px", overflowY: "auto" }}>
<>
<Dashboard
data={currentFilteredData}
theme={theme}
/>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
<Box sx={{ maxHeight: "400px", overflowY: "auto" }}>

<TableContainer component={Paper}>

Expand Down Expand Up @@ -395,6 +402,7 @@ const Home: React.FC = () => {

</TableContainer>
</Box>
</>
)}
</Container>
);
Expand Down