feat: add comprehensive user activity stats to profile page#273
Merged
knoxiboy merged 2 commits intoMay 25, 2026
Merged
Conversation
|
@Harshit-Maurya838 is attempting to deploy a commit to the Karan Mani Tripathi 's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
@knoxiboy Please review this PR and I starred this Repo also |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new “Activity Stats” section to the profile page by introducing a dedicated backend stats endpoint and wiring the frontend to fetch and display additional engagement metrics.
Changes:
- Added
/api/profile/statsendpoint plus a DB aggregation helper to compute per-user activity metrics. - Updated the profile page UI to display a larger stats grid (including likes received, reply upvotes, doubts solved, active subject, member since).
- Extended profile TypeScript types to represent the new activity stats payload.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
types/profile.ts |
Adds ActivityStats and CombinedStats interfaces for new stats data. |
lib/profile/getProfileStats.ts |
New DB aggregation helper used by the stats API. |
app/api/profile/stats/route.ts |
New API route that returns aggregated user activity stats. |
app/profile/page.tsx |
Fetches /api/profile/stats and renders expanded stats grid on the profile page. |
package-lock.json |
Lockfile metadata changes (platform-specific entries adjusted). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+138
to
143
| .then(([profileRes, statsRes]: [ProfileData, { success: boolean, stats: ActivityStats }]) => { | ||
| if (profileRes.user && statsRes.success) { | ||
| setProfileData(profileRes); | ||
| setActivityStats(statsRes.stats); | ||
| setEmailNotificationsEnabled(profileRes.user.emailNotificationsEnabled ?? true); | ||
| } else { |
Comment on lines
+12
to
+15
| const replyQuery = db.select({ | ||
| totalReplies: count(repliesTable.id), | ||
| totalReplyUpvotes: sum(repliesTable.upvotes).mapWith(Number), | ||
| }).from(repliesTable).where(or(eq(repliesTable.userEmail, email), eq(repliesTable.userName, userName))); |
Comment on lines
+24
to
+26
| const rawJoinDate = stats.userCreatedAt || (clerkUser?.createdAt ? new Date(clerkUser.createdAt) : new Date()); | ||
| const memberSince = rawJoinDate instanceof Date ? rawJoinDate.toISOString() : new Date(rawJoinDate).toISOString(); | ||
|
|
Comment on lines
+7
to
+23
| export async function GET(req: Request) { | ||
| try { | ||
| const { userId } = await auth(); | ||
| if (!userId) { | ||
| return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); | ||
| } | ||
|
|
||
| const clerkUser = await currentUser(); | ||
| const email = clerkUser?.primaryEmailAddress?.emailAddress; | ||
| const name = clerkUser?.fullName || clerkUser?.firstName || "Unknown"; | ||
|
|
||
| if (!email) { | ||
| return NextResponse.json({ error: "No email found" }, { status: 400 }); | ||
| } | ||
|
|
||
| const stats = await getProfileStats(email, name); | ||
|
|
knoxiboy
approved these changes
May 25, 2026
Owner
knoxiboy
left a comment
There was a problem hiding this comment.
Automated review: Thank you for starring the repository! The PR is approved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR enhances the DoubtDesk profile page by introducing a comprehensive user activity statistics section to improve engagement visibility and gamification.
The implementation adds optimized backend aggregation APIs along with a responsive frontend stats grid displaying meaningful participation metrics for each user.
Related Issue
Closes #182
Type of Change
Screenshots (if UI change)
How Has This Been Tested?
npm run devChecklist
npm run dev)anytypes)main