Skip to content

feat: implement patch 19#26

Merged
mehdiasadli merged 1 commit into
mainfrom
v26-04-19
Apr 29, 2026
Merged

feat: implement patch 19#26
mehdiasadli merged 1 commit into
mainfrom
v26-04-19

Conversation

@mehdiasadli
Copy link
Copy Markdown
Contributor

@mehdiasadli mehdiasadli commented Apr 29, 2026

Summary by CodeRabbit

  • New Features
    • Added follow and unfollow functionality for other users' profiles
    • Display follower and following counts on public profiles
    • View paginated lists of followers and following users with infinite scroll support
    • Profile actions now show follow/unfollow buttons when visiting other users' profiles (excluding your own)

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
xamsa-web Ready Ready Preview, Comment Apr 29, 2026 7:21am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Implements a complete follow system enabling users to follow/unfollow each other and view follower/following lists. Adds database schema with UserFollow table and aggregate counters, introduces five new API endpoints for follow operations and list queries, integrates React Query for follow state and pagination on the profile route, and updates schemas and release notes accordingly.

Changes

Cohort / File(s) Summary
Database Schema & Enums
packages/db/prisma/schema/auth.prisma, packages/db/prisma/migrations/20260430120000_patch_19_user_follow/migration.sql
Introduces UserFollow model and FollowStatus enum with cascade-delete relations. Adds totalFollowers and totalFollowing integer fields to User table with default values and indexes on follower/following lookups.
Zod Schema Definitions
packages/schemas/src/db/schemas/enums/FollowStatus.schema.ts, packages/schemas/src/db/schemas/enums/UserFollowScalarFieldEnum.schema.ts, packages/schemas/src/db/schemas/enums/UserScalarFieldEnum.schema.ts, packages/schemas/src/db/schemas/models/UserFollow.schema.ts, packages/schemas/src/db/schemas/models/User.schema.ts, packages/schemas/src/db/schemas/models/index.ts
Defines runtime validation schemas for UserFollow, FollowStatus enum, and updates User schema with new aggregate count fields. Adds UserFollowScalarFieldEnum for field validation.
API Endpoint Schemas
packages/schemas/src/modules/user.ts
Adds schemas for follow operations: GetFollowState, FollowUser, UnfollowUser, ListFollowers, ListFollowing. Updates FindOneProfileOutput to include totalFollowers and totalFollowing.
API Router & Service Layer
packages/api/src/modules/user/router.ts, packages/api/src/modules/user/service.ts
Adds five new router endpoints (protected: getFollowState, follow, unfollow; public: listFollowers, listFollowing). Service layer implements follow validation, transactional follow/unfollow with counter updates, idempotent operations, cursor-based pagination, and self-follow prevention.
Frontend Integration
apps/web/src/routes/u/$username.tsx
Integrates React Query for follow state tracking via useQuery, adds two infinite queries for paginated follower/following lists, implements follow/unfollow mutations with toast notifications, adds UI dialog/controls to display follower/following counts with IntersectionObserver-based infinite scroll.
Release & Documentation
packages/utils/src/app-releases.ts, draft.md
Updates app version from patch 18 to 19. Expands specification documentation with follow system requirements, schema details, and product notes on self-follow prevention and count correctness.

Sequence Diagram

sequenceDiagram
    actor User as Signed-in User
    participant Web as Web Client
    participant API as API Server
    participant DB as Database

    User->>Web: Click follow button on profile
    Web->>API: POST /user.follow { targetUsername }
    API->>DB: BEGIN TRANSACTION
    DB->>DB: INSERT INTO user_follow (followerId, followingId, status)
    DB->>DB: UPDATE user SET total_following = total_following + 1
    DB->>DB: UPDATE user SET total_followers = total_followers + 1
    DB->>DB: COMMIT TRANSACTION
    API->>Web: { ok: true }
    Web->>Web: Invalidate follow state query
    Web->>API: GET /user.getFollowState { targetUsername }
    API->>DB: SELECT * FROM user_follow WHERE followerId = ? AND followingId = ? AND status = 'accepted'
    API->>Web: { isFollowing: true }
    Web->>User: Show success toast, update UI

    rect rgba(200, 150, 100, 0.5)
        User->>Web: Click followers count to open dialog
        Web->>API: GET /user.listFollowers { username, limit, cursor? }
        API->>DB: SELECT * FROM user_follow WHERE followingId = ? ORDER BY createdAt DESC LIMIT limit+1
        API->>Web: { items: [...profiles], nextCursor: ... }
        Web->>Web: Render followers list with IntersectionObserver
        Web->>User: Display paginated followers list
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

size:xl, app:web, database

Poem

🐰 Hops of joy across the platform,
Users now can follow forth and.
Aggregate counts in the database gleam,
Cursor-paginated follower dreams.
React Query's infinite scroll,
Makes connections' tracking whole!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and generic. 'feat: implement patch 19' does not convey meaningful information about the specific changes; a reader scanning history would need to investigate the PR details to understand what patch 19 contains. Use a more descriptive title that highlights the main feature, such as 'feat: implement user follow system' or 'feat: add follower/following functionality'. This would clearly communicate the primary change to reviewers.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v26-04-19

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@mehdiasadli mehdiasadli merged commit 33bc666 into main Apr 29, 2026
4 of 5 checks passed
@mehdiasadli mehdiasadli deleted the v26-04-19 branch April 29, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant