feat(db): delete copaing 48 hours after soft delete
This commit is contained in:
parent
698292db49
commit
8e157f56d6
4 changed files with 23 additions and 6 deletions
17
xp/member.go
17
xp/member.go
|
@ -204,6 +204,23 @@ func (c *Copaing) Reset() {
|
|||
gokord.DB.Where("guild_id = ? AND discord_id = ?", c.GuildID, c.DiscordID).Delete(c)
|
||||
}
|
||||
|
||||
func (c *Copaing) AfterDelete(db *gorm.DB) error {
|
||||
id := c.ID
|
||||
dID := c.DiscordID
|
||||
gID := c.GuildID
|
||||
utils.NewTimer(48*time.Hour, func(stop chan struct{}) {
|
||||
if err := db.Unscoped().Where("id = ?", id).Delete(c).Error; err != nil {
|
||||
utils.SendAlert(
|
||||
"xp/member.go - Removing copaing from database", err.Error(),
|
||||
"discord_id", dID,
|
||||
"guild_id", gID,
|
||||
)
|
||||
}
|
||||
stop <- struct{}{}
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func getRedisClient() (*redis.Client, error) {
|
||||
if redisClient == nil {
|
||||
var err error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue