targetcursor profile cursor#6
Open
amormousa wants to merge 8 commits into
Open
Conversation
- Add UpdateProfileStats to upsert cached aggregate stats after session processing - Add GetProfileStats model function for reading cached profile stats - Add RevokeAllUserRefreshTokens and CleanupExpiredRefreshTokens for token management - Add POST /api/auth/logout endpoint to revoke refresh token and clear cookie - Add periodic cleanup of expired refresh tokens on token refresh - Populate user_profile_stats table from session processor background job - Extend User model with all profile fields from migrations
This reverts commit 670b0eb.
|
@amormousa is attempting to deploy a commit to the Majoramari Team on Vercel. A member of the Team first needs to authorize it. |
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.
Pull Request: Profile Page (Backend + Frontend) + Swagger Docs
Overview
This PR adds the full Profile page (backend + frontend) to the Seismic project, along with Swagger documentation updates and a few unrelated UI/auth-flow changes bundled in.
1. Database Migrations (5 new files)
006_extend_users.sqlusers:first_name,role,location,university,time_zone,last_active_at,gender,languages(array)007_profile_stats.sqluser_profile_statstable — cached aggregate coding stats (total seconds, active days, current/max streak) to avoid recomputing on every profile view008_achievements.sqlachievement_types(badge definitions) +user_achievements(links a user to an earned badge + timestamp)009_activity_log.sqlactivity_logtable for the recent-activity feed, plus indexes onsessionsandheartbeatsfor query performance010_problem_stats_placeholder.sqluser_problem_statswith no real logic behind it yet, all zero values. Added purely so the Profile API can already support this shape; there is no actual problem-solving feature in Seismic yetAlso includes two seed files (
seed_dummy_data.sql,seed_profile.sql) that generate fake data for four full users (profile + streaks + achievements + activity) and one simple test-user seed — these are for local testing only, not production.2. Backend (Go / Fiber)
New files
handlers/profile.go— main profile handler:GetProfile(GET/api/profile): aggregates everything about the user (basic info, coding stats, heatmap, achievements, activity, placeholder problem stats, profile-completion percentage) into a single response.UpdateProfile(PATCH/api/profile): updates only whitelisted fields, with validation onbio(max 280 chars) andwebsite(must be a valid URL).computeMemberFor(human-readable "member for X years/months"),computeLastActive("Online now" if <5 min, otherwise relative time),computeInfoCompletion(calculates profile completion % across 5 fields: fullName, bio, location, gender, languages),buildHeatmapGrid(converts flat daily data into a 52-week × 7-day grid with levels 0–4 based on seconds coded).models/profile.go— all profile-related structs and DB queries:ProfileResponse,HeatmapCell,ProfileInfoField,Achievement,ActivityLogItem,UpdateProfileRequestGetProfileStats,UpdateProfileStats(recomputes stats from thesessionstable and upserts)GetProblemStats(returns zero values if no row exists, without inserting one — table is placeholder as noted above)GetProfileAchievements,GetRecentActivityUpdateUserProfile— only updates fields that were actually sent (pointer-based), query built with an explicit whitelist of columns (no risky string concatenation)Modified files
models/user.go— all query functions (FindUserByEmail,FindUserByUsername,FindUserByID,FindUserByAPIKey,CreateUser) updated to fetch the new columns (display_name,first_name,role,location,university,time_zone,gender,languages,last_active_at)routes/routes.go— new/api/profileroute group (GET + PATCH), protected byRequireAuthmain.go— addedPATCHto the allowed CORS methodshandlers/auth.goRequestMagicLink, the code now:devToken)This is explicitly commented as a TEMP DEV BYPASS to make local login testing easier without actually sending an email. This must be removed/reverted before any real deployment — it's a clear security risk, since anyone could log in as any email without ever receiving it.
3. Swagger (
docs/swagger.json)/api/profileendpoints (GET + PATCH) with full response schemasmodels.Achievement,models.ActivityLogItem,models.HeatmapCell,models.ProfileInfoField,models.ProfileMetric,models.ProfileResponse,models.UpdateProfileRequestmodels.Heartbeat(addedtimezone)4. Frontend (Angular)
New Profile page (
pages/profile/)profile.ts(434 lines) — component that usesProfileServiceto fetch and display profile data, and allows editingprofile.html(419 lines) — template: profile card, metrics, heatmap, achievements, activity feed, info-completion widgetprofile.css(914 lines) — full stylingprofile.service.ts— defines all interfaces matching the backend response (ProfileResponse,HeatmapCell,Achievement, etc.) and exposesgetProfile()/updateProfile()viaApiServiceRelated changes
core/api/api.service.ts— added a newpatch<T>()method (previously only get/post/delete existed)app.routes.ts— added/profileroute, protected byauthGuardauth/login.tsandauth/verify.ts— after login/verify, users are now redirected to/profileinstead of/dashboard(login also now reads thedevTokenintroduced inauth.goto auto-navigate to the verify page — this is an extension of the same dev bypass and should be removed together with it)Unrelated UI changes bundled in
app.html— still contains unresolved merge conflict markers (<<<<<<< HEAD/=======/>>>>>>>) that must be resolved before merging, plus the addition of a new<app-target-cursor>componentapp.ts— imports and enables a newTargetCursorComponentshared/components/target-cursor/(new file, 473 lines) andshared/components/magic-bento/(directive + CSS, ~640 lines) — new UI components for visual effects (custom cursor + bento grid glow effect); not clear from this diff where else they're actually used besides being wired up inapp.ts/app.htmlangular.json— added ananalyticsID (inside the same merge conflict)package.json— added dependencies:fdir,gsap(likely for the new animation components)app.htmlhas unresolved merge conflict markers — the file is currently brokenauth.gohas a dev bypass that returns the magic-link token in the API response and swallows email-send failures — a security issue if this ships to production010_problem_stats_placeholder.sqland everything wired to it (GetProblemStats,Solved/TotalProblems/Attemptingin the response) are explicit placeholders — values are always empty/zero until a real problem-solving feature exists