Skip to content

Draft: Rearchitect users with the help of Kilocode without GKG

What does this MR do and why?

Rearchitect users with the help of Kilocode without GKG

Relates to #213

Video of Execution Kilo without GKG

kilo_without_gkg

Summary

Took ~3 minutes

Result:

I have successfully rearchitected the users table to support non-GitLab contributors in the Contributor Platform. Here's what was implemented:

Key Changes Made:

  1. Database Migration (20250515000000_rearchitect_users_for_non_gitlab_contributors.rb):

    • Renamed id column to gitlab_user_id
    • Added new auto-incrementing id as primary key
    • Added unique index on gitlab_user_id where not null
    • Existing GitLab users retain their original ID in gitlab_user_id
    • New non-GitLab users have gitlab_user_id as null
  2. User Model Updates (app/models/user.rb):

    • Added gitlab_user? method to check if user has GitLab account
    • Updated web_url to return nil for non-GitLab users
    • Added scopes for gitlab_users and non_gitlab_users
  3. Routing Changes (config/routes.rb):

    • Changed leaderboard user route from :username to :id with numeric constraint
    • Updated leaderboard controller to find users by ID instead of username
  4. Data Import Services:

    • Discord (app/services/discord_service.rb): Now creates users for Discord contributors without GitLab accounts, using unique usernames
    • Discourse (app/services/discourse_service.rb): Creates users for forum contributors without GitLab accounts
    • Crowdin (app/services/crowdin_service.rb): Creates users for translation contributors without GitLab accounts
  5. Backward Compatibility:

    • Existing GitLab users continue to work unchanged
    • Foreign key references remain valid as they point to the new id column
    • Activity summary views and queries work with the new schema

How It Works:

  • GitLab Users: Have gitlab_user_id set, web_url returns GitLab profile link
  • Non-GitLab Users: Have gitlab_user_id null, web_url returns nil
  • Unique Identification: All users have a unique id for routing and references
  • Data Import: Services automatically create user records for contributors from Discord, Discourse, and Crowdin who don't have GitLab accounts

Next Steps:

The frontend Vue application will need to be updated to use user IDs instead of usernames for routing and links, but the backend API now supports both GitLab and non-GitLab contributors fully.

The implementation maintains all existing functionality while extending support to contributors active only in Discord, Discourse, or Crowdin.

/cc @leetickett-gitlab

Merge request reports

Loading