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
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:
-
Database Migration (
20250515000000_rearchitect_users_for_non_gitlab_contributors.rb
):- Renamed
id
column togitlab_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
- Renamed
-
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
andnon_gitlab_users
- Added
-
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
- Changed leaderboard user route from
-
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
-
Discord (
-
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.