Repository navigation
File a deleted user's usage under a label of its own - #44
Merged
Merged
Conversation
Usage is recorded under the user's name, which outlives the account. When an admin deleted bob and later created another bob, the new account's usage page showed the first bob's requests, tokens and monthly totals, and the admin's per-user views merged the two people. Deleting a user now moves their per-request rows and monthly totals to "bob (deleted 2026-10-09 14:03:12)". The history stays readable for the admin, and a later bob starts with none of it. The move runs behind the ledger writes already queued, so their last requests move too. Labels can't collide with usernames, which never hold spaces or brackets. Playground calls were recorded as yardmaster-playground, a valid username, so a user given that name would have seen them as their own. They are now recorded as (playground). Fixes #27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #27.
Usage is recorded under the user's name, which outlives the account. If an admin deleted
boband later created anotherbob, the new account's usage page showed the first bob's requests, tokens and monthly totals. The admin's per-user views also merged the two people.Delete now relabels. Deleting a user moves their per-request rows and monthly totals to
bob (deleted 2026-10-09 14:03:12).bobstarts with none of it.Ledger.RelabelUserruns on the ledger's own queue, behind writes already queued, so the user's last requests move too. It waits for room in the queue rather than being dropped.Playground label. Playground calls were recorded as
yardmaster-playground, a valid username, so a user given that name would see them as their own. They are now recorded as(playground). Rows already recorded under the old name stay under it.Why not filter by user ID?
users.idhas noAUTOINCREMENT, so SQLite hands the ID of a deleted newest user to the next one.usage_monthlyis keyed by name only. Both would have needed table rebuilds to fix, and the per-user views would still have merged people.Not covered: names that were already reused before this change. Their merged history can't be split.
Tests:
TestRelabelUserMovesAllTheirUsage(ledger, including pruned monthly totals).TestDeletedUsersUsageIsntInherited(through the API). It fails without the change.