Merge pull request #894 from shocknet/activate-users-cleanup

activte cleanup
This commit is contained in:
Justin (shocknet) 2026-03-02 14:34:37 -05:00 committed by GitHub
commit 71b55c06d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 6 deletions

View file

@ -391,7 +391,7 @@ export class AdminManager {
liquidityProviders.push(liquidityEntry) liquidityProviders.push(liquidityEntry)
} }
} }
const usersBalance = await this.storage.paymentStorage.GetTotalUsersBalance() const usersBalance = await this.storage.paymentStorage.GetTotalUsersBalance(true)
return { return {
users_balance: usersBalance, users_balance: usersBalance,
lnds, lnds,

View file

@ -132,12 +132,12 @@ export default class {
} }
this.log("Found", toDelete.length, "inactive users to delete") this.log("Found", toDelete.length, "inactive users to delete")
// await this.RemoveUsers(toDelete) await this.LockUsers(toDelete.map(u => u.userId))
} }
async CleanupNeverActiveUsers() { async CleanupNeverActiveUsers() {
this.log("Cleaning up never active users") this.log("Cleaning up never active users")
const inactiveUsers = await this.storage.userStorage.GetInactiveUsers(30) const inactiveUsers = await this.storage.userStorage.GetInactiveUsers(90)
const toDelete: { userId: string, appUserIds: string[] }[] = [] const toDelete: { userId: string, appUserIds: string[] }[] = []
for (const u of inactiveUsers) { for (const u of inactiveUsers) {
const user = await this.storage.userStorage.GetUser(u.user_id) const user = await this.storage.userStorage.GetUser(u.user_id)
@ -161,7 +161,15 @@ export default class {
} }
this.log("Found", toDelete.length, "never active users to delete") this.log("Found", toDelete.length, "never active users to delete")
// await this.RemoveUsers(toDelete) TODO: activate deletion await this.RemoveUsers(toDelete)
}
async LockUsers(toLock: string[]) {
this.log("Locking", toLock.length, "users")
for (const userId of toLock) {
await this.storage.userStorage.BanUser(userId)
}
this.log("Locked users")
} }
async RemoveUsers(toDelete: { userId: string, appUserIds: string[] }[]) { async RemoveUsers(toDelete: { userId: string, appUserIds: string[] }[]) {

View file

@ -452,8 +452,12 @@ export default class {
} }
} }
async GetTotalUsersBalance(txId?: string) { async GetTotalUsersBalance(excludeLocked?: boolean, txId?: string) {
const total = await this.dbs.Sum<User>('User', "balance_sats", {}) const where: { locked?: boolean } = {}
if (excludeLocked) {
where.locked = false
}
const total = await this.dbs.Sum<User>('User', "balance_sats", where, txId)
return total || 0 return total || 0
} }