adds maintenance function to clear all users' token records

This commit is contained in:
nai-degen
2023-08-30 22:38:33 -05:00
parent ffc0c6472e
commit 4b32130eaa
4 changed files with 60 additions and 20 deletions
+9
View File
@@ -228,6 +228,15 @@ export function refreshQuota(token: string) {
usersToFlush.add(token);
}
export function resetUsage(token: string) {
const user = users.get(token);
if (!user) return;
const { tokenCounts } = user;
const counts = Object.entries(tokenCounts) as [ModelFamily, number][];
counts.forEach(([model]) => (tokenCounts[model] = 0));
usersToFlush.add(token);
}
/** Disables the given user, optionally providing a reason. */
export function disableUser(token: string, reason?: string) {
const user = users.get(token);