pcgamedb/task/clean.go
nite07 543210a4ae
All checks were successful
docker / prepare-and-build (push) Successful in 2m49s
release / goreleaser (push) Successful in 24m5s
reorganized game infos
change ranking route to popular route
2024-11-22 23:50:36 +08:00

37 lines
992 B
Go

package task
import (
"pcgamedb/db"
"go.uber.org/zap"
)
func Clean(logger *zap.Logger) {
ids, err := db.DeduplicateGameItems()
if err != nil {
logger.Error("Failed to deduplicate games", zap.Error(err))
}
for _, id := range ids {
logger.Info("Deduplicated game", zap.Any("game_id", id))
}
idmap, err := db.CleanOrphanGamesInGameInfos()
if err != nil {
logger.Error("Failed to clean orphan games", zap.Error(err))
}
for _, id := range idmap {
logger.Info("Cleaned orphan game in game info", zap.Any("in", id), zap.Any("removed", idmap[id]))
}
ids, err = db.CleanGameInfoWithEmptyGameIDs()
if err != nil {
logger.Error("Failed to clean game info with empty game ids", zap.Error(err))
}
for _, id := range ids {
logger.Info("Cleaned game info with empty game ids", zap.Any("game_id", id))
}
err = db.MergeGameInfosWithSameName()
if err != nil {
logger.Error("Failed to merge same name game infos", zap.Error(err))
}
logger.Info("Cleaning task completed")
}