Skip to content

Submission Analytics Dashboard for Admins (T113 )#46#66

Merged
krishnapaljadeja merged 12 commits intogdg-charusat:mainfrom
tarun-baranwal:main
Feb 28, 2026
Merged

Submission Analytics Dashboard for Admins (T113 )#46#66
krishnapaljadeja merged 12 commits intogdg-charusat:mainfrom
tarun-baranwal:main

Conversation

@tarun-baranwal
Copy link
Copy Markdown
Contributor

Team Number : Team 113

Description

This PR implements the Submission Analytics Dashboard for admins as described in issue #46.

Related Issue

Closes #46

Type of Change

Added API endpoints to fetch submission analytics:

Number of submissions per day
Average pass/fail rate per challenge
Challenges with the highest fail rates
Updated Prisma schema and migrations to support analytics queries
Updated backend services for computing analytics data
Optional: Ready for visual graphs integration on the frontend
Minor fixes in auth service and Prisma relations

Changes Made:

Prisma Schema Updates
Added DailySubmission relations in prisma/schema.prisma to properly link User and Challenge.
Fixed missing opposite relation fields to resolve Prisma validation errors.
Ensured DailySubmission, User, and Challenge models have correct @relation mappings.

Authentication Service Fixes
Updated auth.service.js for proper registration and login after schema changes.
Verified that getProfile and updateProfile endpoints function as expected.

Admin Analytics Implementation
Created admin.controller.js and admin.service.js to provide submission analytics for admins.

Other Fixes and Improvements
Updated migrations to fix existing database schema issues.
Cleared test user data and ensured DB consistency.
Updated .env handling for smooth local development.

Screenshots (if applicable)

Before:

After:
1a
2a

Testing

  • Tested on Desktop (Chrome/Firefox/Safari)
  • Tested on Mobile (iOS/Android)
  • Tested responsive design (different screen sizes)
  • No console errors or warnings
  • Code builds successfully (npm run build)

Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my code
  • I have commented my code where necessary
  • My changes generate no new warnings
  • I have tested my changes thoroughly
  • All TypeScript types are properly defined
  • Tailwind CSS classes are used appropriately (no inline styles)
  • Component is responsive across different screen sizes
  • I have read and followed the CONTRIBUTING.md guidelines

Additional Notes

@krishnapaljadeja krishnapaljadeja self-requested a review February 26, 2026 19:02
@krishnapaljadeja krishnapaljadeja added the needs-review Valid issue-linked PR awaiting review label Feb 26, 2026
@krishnapaljadeja
Copy link
Copy Markdown
Contributor

✅ PR Validation Passed

Hey @tarun-baranwal! Your PR looks good. Here is what we found:

Field Value
Team Number Team 113
Linked Issue Closes #46

A maintainer will review your PR within 24–48 hours. Stay responsive to feedback!

GDG CHARUSAT Open Source Contri Sprintathon

DeepPatel4505 and others added 7 commits February 28, 2026 18:18
…vice methods

- Replace per-membership prisma.dailyResult loops in getDashboard and
  getTodayStatus with two bulk queries using memberId: { in: memberIds }
- Add getBulkTodayResults() and getBulkMemberDailyResults() service methods
  that fetch all results in one query and return maps keyed by memberId
- Add normaliseToMidnight() helper to centralise date normalisation logic
- Group results in-memory via reduce for O(1) controller-level lookup
- Add normaliseToMidnight() helper to centralise date normalisation logic
- Fixes 30+ DB queries per request (15 challenges) down to 3 queries for
  getDashboard and 2 for getTodayStatus

Closes gdg-charusat#21
- Fix N+1 in getChallengeLeaderboard: replace per-member prisma loop
  with getBulkAllMemberResults() which fetches all dailyResult rows for
  all members in one query (selecting only memberId + completed) and
  aggregates totalDays/completedDays in-memory
- Use normaliseToMidnight() in getTodayStatus service function instead
  of inline setHours pattern, consistent with new helper convention
- Export getBulkAllMemberResults from evaluation.service.js
- Created `prisma/seed.js` to seed the database with sample users, problems, challenges, memberships, daily results, and penalty ledger entries.
- Updated `package.json` to include seed scripts for easy execution.
- Added `Postman_Collection.json` for API endpoints testing, including health checks, authentication, challenge management, dashboard analytics, and LeetCode integration.
- Introduced `postman_environment.json` for environment variable management in Postman.
- Documented the seeding and testing process in `SEEDING_AND_TESTING.md` for user guidance.
- Created `postman/postman_README.md` to provide an overview of Postman files and quick start instructions.
@krishnapaljadeja krishnapaljadeja added needs-review Valid issue-linked PR awaiting review and removed needs-review Valid issue-linked PR awaiting review labels Feb 28, 2026
@krishnapaljadeja krishnapaljadeja added needs-review Valid issue-linked PR awaiting review and removed needs-review Valid issue-linked PR awaiting review labels Feb 28, 2026
@krishnapaljadeja
Copy link
Copy Markdown
Contributor

@tarun-baranwal can you please remove package-lock.json from the commit and rebase it. thankyou

@krishnapaljadeja krishnapaljadeja added needs-review Valid issue-linked PR awaiting review and removed needs-review Valid issue-linked PR awaiting review labels Feb 28, 2026
@krishnapaljadeja krishnapaljadeja added needs-review Valid issue-linked PR awaiting review and removed needs-review Valid issue-linked PR awaiting review labels Feb 28, 2026
@krishnapaljadeja krishnapaljadeja added needs-review Valid issue-linked PR awaiting review and removed needs-review Valid issue-linked PR awaiting review labels Feb 28, 2026
@krishnapaljadeja krishnapaljadeja merged commit d0d261b into gdg-charusat:main Feb 28, 2026
1 check passed
@krishnapaljadeja
Copy link
Copy Markdown
Contributor

🎉 PR Merged — Points Awarded!

Congratulations @tarun-baranwal! Your contribution has been merged.

Field Value
Repo Code_duel_backend
Team Team 113
Contributor @tarun-baranwal
Level Level 2 — Intermediate
Points Awarded 20 pts
Source Linked Issue #46

The central leaderboard has been updated. Keep contributing!

GDG CHARUSAT Open Source Contri Sprintathon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review Valid issue-linked PR awaiting review pr-noted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build a Submission Analytics Dashboard for Admins.(T113)

8 participants