added account name reserving time

alpha
alex 2023-03-05 06:58:28 +01:00
parent 9bef619b5a
commit 0570299518
2 changed files with 8 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package scylladb
import (
"time"
"clickandjoin.app/managementsystem/modules/utils"
gocnjhelper "git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper"
"git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper/dbstructs"
"github.com/gocql/gocql"
@ -15,6 +16,8 @@ func TableCleaner() {
// handling expired userSignUpProcesses
time.Sleep(duration)
var userSignUpProcesses []dbstructs.UserSignUpProcess
if err := Session.Query(gocnjhelper.DbMUserSignUpProcess.SelectAll()).SelectRelease(&userSignUpProcesses); err != nil {
@ -58,7 +61,7 @@ func TableCleaner() {
var updatingUsers []dbstructs.User
accountNameReservingTime := currentTime.Add(-7 * 24 * time.Hour).Unix()
accountNameReservingTime := currentTime.Add(-utils.AccountNameReservingTime * 24 * time.Hour).Unix()
for _, u := range users {
if u.LastAccountNameLc != "" && u.AccountNameUpdatedAt < accountNameReservingTime {
@ -81,8 +84,6 @@ func TableCleaner() {
}
}
time.Sleep(duration)
// restart timer
go TableCleaner()
}

View File

@ -1,3 +1,6 @@
package utils
const CachedLastLogMessages = 499 // Number of messages held in the cache and sent to new clients to receive the latest messages
const (
CachedLastLogMessages = 499 // Number of messages held in the cache and sent to new clients to receive the latest messages
AccountNameReservingTime = 7 // Days the name should remain reserved
)