🗑️ Clean up cleaner code
This commit is contained in:
		| @@ -1,23 +0,0 @@ | ||||
| package services | ||||
|  | ||||
| import ( | ||||
| 	"git.solsynth.dev/hypernet/interactive/pkg/internal/database" | ||||
| 	"github.com/rs/zerolog/log" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| func DoAutoDatabaseCleanup() { | ||||
| 	deadline := time.Now().Add(60 * time.Minute) | ||||
| 	log.Debug().Time("deadline", deadline).Msg("Now cleaning up entire database...") | ||||
|  | ||||
| 	var count int64 | ||||
| 	for _, model := range database.AutoMaintainRange { | ||||
| 		tx := database.C.Unscoped().Delete(model, "deleted_at >= ?", deadline) | ||||
| 		if tx.Error != nil { | ||||
| 			log.Error().Err(tx.Error).Msg("An error occurred when running auth context cleanup...") | ||||
| 		} | ||||
| 		count += tx.RowsAffected | ||||
| 	} | ||||
|  | ||||
| 	log.Debug().Int64("affected", count).Msg("Clean up entire database accomplished.") | ||||
| } | ||||
| @@ -67,7 +67,6 @@ func main() { | ||||
|  | ||||
| 	// Configure timed tasks | ||||
| 	quartz := cron.New(cron.WithLogger(cron.VerbosePrintfLogger(&log.Logger))) | ||||
| 	quartz.AddFunc("@every 60m", services.DoAutoDatabaseCleanup) | ||||
| 	quartz.AddFunc("@every 5m", services.FlushPostViews) | ||||
| 	quartz.Start() | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user