Skip to content

Commit 3023344

Browse files
feat: Update getRecentSubmissions to accept a limit parameter and adjust dashboard display for improved data visualization
1 parent 1fe140f commit 3023344

File tree

3 files changed

+43
-22
lines changed

3 files changed

+43
-22
lines changed

app/api/leetcode/userDetails/route.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export async function GET() {
2727
// Fetch all data concurrently
2828
const [userDetails, recentSubmissions, languageStats, userContestRanking] = await Promise.all([
2929
getLeetCodeUserDetails(LeetCodeUsername),
30-
getRecentSubmissions(LeetCodeUsername),
30+
getRecentSubmissions(LeetCodeUsername, 6),
3131
getLanguageStats(LeetCodeUsername),
3232
getUserContestRanking(LeetCodeUsername)
3333
]);

app/dashboard/page.tsx

+40-20
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,6 @@ export default function Dashboard() {
175175
<span className="text-sm truncate group-hover:text-blue-600 transition-colors">
176176
{submission.title}
177177
</span>
178-
<span className={`text-xs px-2 py-1 rounded ${
179-
submission.status === 'Accepted'
180-
? 'bg-green-100 text-green-700'
181-
: 'bg-red-100 text-red-700'
182-
}`}>
183-
{submission.status}
184-
</span>
185178
</Link>
186179
))}
187180
</div>
@@ -226,21 +219,48 @@ export default function Dashboard() {
226219
<h3 className="font-semibold">Difficulty Distribution</h3>
227220
</div>
228221
</CardHeader>
229-
<CardContent className="p-4">
230-
<div className="h-48">
222+
<CardContent className="p-4 flex justify-center">
223+
<div className="h-56 w-56">
231224
<Doughnut
232-
data={difficultyData}
233-
options={{
234-
cutout: '70%',
235-
plugins: {
236-
legend: { position: 'bottom' },
237-
tooltip: {
238-
callbacks: {
239-
label: (item) => `${item.label}: ${item.raw} solved`
240-
}
241-
}
225+
data={difficultyData}
226+
options={{
227+
cutout: '65%',
228+
responsive: true,
229+
maintainAspectRatio: true,
230+
plugins: {
231+
legend: {
232+
position: 'bottom',
233+
align: 'center',
234+
labels: {
235+
padding: 20,
236+
usePointStyle: true,
237+
}
238+
},
239+
tooltip: {
240+
backgroundColor: 'rgba(0, 0, 0, 0.8)',
241+
padding: 12,
242+
titleFont: {
243+
size: 14,
244+
weight: 'bold'
245+
},
246+
bodyFont: {
247+
size: 13
248+
},
249+
callbacks: {
250+
label: (context) => {
251+
const total = context.dataset.data.reduce((a: number, b: number) => a + b, 0);
252+
const percentage = ((context.raw as number / total) * 100).toFixed(1);
253+
return `${context.label}: ${context.raw} (${percentage}%)`;
242254
}
243-
}}
255+
}
256+
}
257+
},
258+
animation: {
259+
animateScale: true,
260+
animateRotate: true,
261+
duration: 2000
262+
}
263+
}}
244264
/>
245265
</div>
246266
</CardContent>

utils/leetcode/leetcodeContollers.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ export const getLeetCodeUserDetails = async (username: string) => {
1313
return response.data.matchedUser;
1414
}
1515

16-
export const getRecentSubmissions = async (username: string) => {
16+
export const getRecentSubmissions = async (username: string, limit: number ) => {
1717
const response = await queryLeetCodeAPI(recentSubmissionList, {
1818
username: username,
19+
limit: limit,
1920
});
2021

2122
return response.data.recentSubmissionList;

0 commit comments

Comments
 (0)