Skip to content

Conversation

@yanekyuk
Copy link
Contributor

@yanekyuk yanekyuk commented Jan 23, 2026

Summary

This PR adds a development endpoint to generate missing user profiles in bulk.

What was implemented

  • New endpoint: POST /dev/generate-missing-profiles in src/routes/dev.ts
  • New service methods in src/services/profile.service.ts:
    • getUsersWithoutProfiles(): Finds all users who don't have a profile yet
    • createInitialProfile(): Creates a profile generation job using available user info

Why it was added

Some users may have been created before the automatic profile generation was in place, or their profile generation may have failed. This endpoint allows developers to trigger profile generation for all users who are missing profiles, ensuring data consistency.

How it works

  1. The endpoint queries for all users without profiles
  2. For each user found, it queues a profile generation job using the existing profileQueue
  3. The job uses available user information (name, email, location, socials) to generate the profile

How to test

# Call the endpoint (requires dev environment)
curl -X POST http://localhost:3000/dev/generate-missing-profiles

The response includes:

  • count: Number of users found without profiles
  • users: List of user IDs that were queued for profile generation

Summary by CodeRabbit

  • New Features

    • Added automatic profile generation capability for users without existing profiles, with comprehensive status tracking and error reporting.
  • Improvements

    • Enhanced profile initialization process with improved service methods for managing user profiles.

✏️ Tip: You can customize this high-level summary in your review settings.

- Add getUsersWithoutProfiles() method to ProfileService
- Add createInitialProfile() method to ProfileService
- Add POST /dev/generate-missing-profiles endpoint
- Endpoint queues profile generation jobs for all users lacking profiles
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The changes introduce profile generation functionality by adding a new dev endpoint that identifies users without profiles, creates initial profile records, and queues profile-update jobs. Supporting methods in ProfileService retrieve users lacking profiles and create minimal profile entries.

Changes

Cohort / File(s) Summary
Dev Endpoint for Profile Generation
protocol/src/routes/dev.ts
Added POST /generate-missing-profiles endpoint that fetches users without profiles, creates initial profiles, and queues profile-update jobs. Modified imports to use addOpportunityJob and addProfileJob aliases. Enhanced logging for development flow.
Profile Service Methods
protocol/src/services/profile.service.ts
Added public methods getUsersWithoutProfiles() to retrieve users lacking profiles and createInitialProfile() to create minimal initial profile records. Includes new imports for notInArray and users schema.

Sequence Diagram

sequenceDiagram
    participant Client as Dev API Client
    participant Dev as POST /generate-missing-profiles
    participant ProfileSvc as ProfileService
    participant DB as Database
    participant Queue as Job Queue

    Client->>Dev: POST /generate-missing-profiles
    Dev->>ProfileSvc: getUsersWithoutProfiles()
    ProfileSvc->>DB: Query users without profiles
    DB-->>ProfileSvc: Return user list
    ProfileSvc-->>Dev: Array of users

    alt Users found
        loop For each user
            Dev->>ProfileSvc: createInitialProfile(userId, name, ...)
            ProfileSvc->>DB: Insert initial profile record
            DB-->>ProfileSvc: Confirmation
            Dev->>Queue: addProfileJob(user)
            Queue-->>Dev: Job queued
        end
        Dev-->>Client: 200 OK with summary (total, queued)
    else No users found
        Dev-->>Client: 200 OK with queued: 0
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Whiskers twitching with delight
Missing profiles? Not on my watch tonight!
Queue them up, create with care,
Database hops—profiles everywhere! ✨
The burrow grows complete and bright!

✨ Finishing touches
  • 📝 Generate docstrings

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

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

@serefyarar serefyarar merged commit de35f10 into indexnetwork:dev Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants