serial id
This commit is contained in:
parent
be6f48427f
commit
cfb7dd1e6e
2 changed files with 15 additions and 4 deletions
|
|
@ -176,6 +176,11 @@ export default class {
|
||||||
this.log("Deleting", toDelete.length, "inactive users")
|
this.log("Deleting", toDelete.length, "inactive users")
|
||||||
for (let i = 0; i < toDelete.length; i++) {
|
for (let i = 0; i < toDelete.length; i++) {
|
||||||
const { userId, appUserIds } = toDelete[i]
|
const { userId, appUserIds } = toDelete[i]
|
||||||
|
const user = await this.storage.userStorage.FindUser(userId)
|
||||||
|
if (!user || user.balance_sats > 0) {
|
||||||
|
if (user) this.log("Skipping user", userId, "has balance", user.balance_sats)
|
||||||
|
continue
|
||||||
|
}
|
||||||
this.log("Deleting user", userId, "progress", i + 1, "/", toDelete.length)
|
this.log("Deleting user", userId, "progress", i + 1, "/", toDelete.length)
|
||||||
await this.storage.StartTransaction(async tx => {
|
await this.storage.StartTransaction(async tx => {
|
||||||
for (const appUserId of appUserIds) {
|
for (const appUserId of appUserIds) {
|
||||||
|
|
|
||||||
|
|
@ -162,9 +162,15 @@ export default class {
|
||||||
}
|
}
|
||||||
|
|
||||||
async RemoveAppUsersAndBaseUsers(appUserIds: string[], baseUser: string, txId?: string) {
|
async RemoveAppUsersAndBaseUsers(appUserIds: string[], baseUser: string, txId?: string) {
|
||||||
await this.dbs.Delete<ApplicationUser>('ApplicationUser', { identifier: In(appUserIds) }, txId)
|
if (appUserIds.length > 0) {
|
||||||
await this.dbs.Delete<User>('User', { user_id: baseUser }, txId)
|
const appUsers = await this.dbs.Find<ApplicationUser>('ApplicationUser', { where: { identifier: In(appUserIds) } }, txId)
|
||||||
|
for (const appUser of appUsers) {
|
||||||
|
await this.dbs.Delete<ApplicationUser>('ApplicationUser', appUser.serial_id, txId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const user = await this.userStorage.FindUser(baseUser, txId)
|
||||||
|
if (!user) return
|
||||||
|
await this.dbs.Delete<User>('User', user.serial_id, txId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue