pcgamedb/task/clean.go

37 lines
1002 B
Go
Raw Normal View History

2024-09-24 06:17:11 -04:00
package task
import (
2024-11-20 06:09:04 -05:00
"pcgamedb/db"
2024-09-24 06:17:11 -04:00
"go.uber.org/zap"
)
func Clean(logger *zap.Logger) {
ids, err := db.DeduplicateGameItems()
2024-09-24 06:17:11 -04:00
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))
}
2024-11-28 06:34:54 -05:00
err = db.MergeGameInfosWithSameIGDBID()
2024-09-24 06:17:11 -04:00
if err != nil {
2024-11-28 06:34:54 -05:00
logger.Error("Failed to merge game infos with same igdb id", zap.Error(err))
2024-09-24 06:17:11 -04:00
}
logger.Info("Cleaning task completed")
2024-09-24 06:17:11 -04:00
}