Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account renames are not tracked well #194

Open
redfast00 opened this issue Dec 7, 2023 · 2 comments
Open

Account renames are not tracked well #194

redfast00 opened this issue Dec 7, 2023 · 2 comments

Comments

@redfast00
Copy link
Member

@Z03-L is not showing up in the leaderboard, despite having merged PR's and commits (ZeusWPI/hydra-react-native#23); she's also member of the GitHub organisation. She did change her nickname; see DM's.

@chvp chvp self-assigned this Dec 7, 2023
@chvp
Copy link
Member

chvp commented Dec 8, 2023

A reseed of the database seems to have fixed this. Not sure what happened, I couldn't find any trace of the old username in the database, but the new one didn't seem to have been picked up either. The specific case is fixed for now, but keeping this issue open, since the root cause wasn't fixed.

@chvp chvp changed the title People not showing up in Gamification leaderboard Account renames are not tracked well Dec 9, 2023
@chvp
Copy link
Member

chvp commented Dec 9, 2023

I figured out why I couldn't find any trace of the old username (default scopes are evil), and I fully get the issue now. Unfortunately, it is also not trivial to fix, so I probably won't bother right now (the application is robust to reseeds, and this will probably only seldomly occur).

If anyone wants to fix this in the future, a detailed issue description:

GitIdentitys are created from commits, and linked to a Coder. Each Commit is linked to a Coder, by looking up the GitIdentity with the underlying commit's author name and author email. The GitIdentity is not linked to the Commit database object.

If we want to be able to "see" an account rename, we would have to do a GitHub API lookup every time we look up a GitIdentity. This is not that hard, and would fix the issue for future commits. I'm going to leave it as an open question whether doing that many API lookups would be wanted. Also, only doing this e.g. once an hour would definitely reduce it to an acceptable level (but be more work to implement, obviously).

To fix the issue for past commits, Commits should probably be linked to a Coder via a GitIdentity, instead of directly. This would make most of the queries performed a bit more complicated, but probably not problematically so. Care should be taken to update CommitStats, since there are some manual queries in there. Also make sure to inspect any includes calls, to make sure they still avoid N+1 queries correctly.

Doing all of the above would leave the old usernames lying around in the database as Coder objects. To avoid this, Coder should probably get a field for the actual GitHub id (where uniqueness of that field is enforced). If an account is fetched from GitHub with a known GitHub id, the name and username could just be updated. This would also fix the issue of updating old commits. The current Coders in the database don't have this field however, and writing a migration for this will be quite hard. (Of course, a reseed of the database is always possible, so this is not necessarily as big an issue as it seems.)

@chvp chvp removed their assignment Dec 9, 2023
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

No branches or pull requests

2 participants