Compare commits

..

4 Commits

Author SHA1 Message Date
2ec5d0e2e3 u 2025-05-17 18:16:03 +10:00
020d005d97 u 2025-05-17 18:03:56 +10:00
577a17bac7 u 2025-05-17 17:29:48 +10:00
ea4d01c9a6 u 2025-05-17 15:13:54 +10:00
6 changed files with 666 additions and 111 deletions

View File

@ -26,74 +26,74 @@ func StartWebhookServer(client *igdb.Client) {
log.Fatalf("failed to parse url: %v", err) log.Fatalf("failed to parse url: %v", err)
} }
http.HandleFunc(webhook(client.AgeRatingCategories)) http.HandleFunc(webhook(client.AgeRatingCategories, client))
http.HandleFunc(webhook(client.AgeRatingContentDescriptions)) http.HandleFunc(webhook(client.AgeRatingContentDescriptions, client))
http.HandleFunc(webhook(client.AgeRatingContentDescriptionsV2)) http.HandleFunc(webhook(client.AgeRatingContentDescriptionsV2, client))
http.HandleFunc(webhook(client.AgeRatingOrganizations)) http.HandleFunc(webhook(client.AgeRatingOrganizations, client))
http.HandleFunc(webhook(client.AgeRatings)) http.HandleFunc(webhook(client.AgeRatings, client))
http.HandleFunc(webhook(client.AlternativeNames)) http.HandleFunc(webhook(client.AlternativeNames, client))
http.HandleFunc(webhook(client.Artworks)) http.HandleFunc(webhook(client.Artworks, client))
http.HandleFunc(webhook(client.CharacterGenders)) http.HandleFunc(webhook(client.CharacterGenders, client))
http.HandleFunc(webhook(client.CharacterMugShots)) http.HandleFunc(webhook(client.CharacterMugShots, client))
http.HandleFunc(webhook(client.Characters)) http.HandleFunc(webhook(client.Characters, client))
http.HandleFunc(webhook(client.CharacterSpecies)) http.HandleFunc(webhook(client.CharacterSpecies, client))
http.HandleFunc(webhook(client.CollectionMemberships)) http.HandleFunc(webhook(client.CollectionMemberships, client))
http.HandleFunc(webhook(client.CollectionMembershipTypes)) http.HandleFunc(webhook(client.CollectionMembershipTypes, client))
http.HandleFunc(webhook(client.CollectionRelations)) http.HandleFunc(webhook(client.CollectionRelations, client))
http.HandleFunc(webhook(client.CollectionRelationTypes)) http.HandleFunc(webhook(client.CollectionRelationTypes, client))
http.HandleFunc(webhook(client.Collections)) http.HandleFunc(webhook(client.Collections, client))
http.HandleFunc(webhook(client.CollectionTypes)) http.HandleFunc(webhook(client.CollectionTypes, client))
http.HandleFunc(webhook(client.Companies)) http.HandleFunc(webhook(client.Companies, client))
http.HandleFunc(webhook(client.CompanyLogos)) http.HandleFunc(webhook(client.CompanyLogos, client))
http.HandleFunc(webhook(client.CompanyStatuses)) http.HandleFunc(webhook(client.CompanyStatuses, client))
http.HandleFunc(webhook(client.CompanyWebsites)) http.HandleFunc(webhook(client.CompanyWebsites, client))
http.HandleFunc(webhook(client.Covers)) http.HandleFunc(webhook(client.Covers, client))
http.HandleFunc(webhook(client.DateFormats)) http.HandleFunc(webhook(client.DateFormats, client))
http.HandleFunc(webhook(client.EventLogos)) http.HandleFunc(webhook(client.EventLogos, client))
http.HandleFunc(webhook(client.EventNetworks)) http.HandleFunc(webhook(client.EventNetworks, client))
http.HandleFunc(webhook(client.Events)) http.HandleFunc(webhook(client.Events, client))
http.HandleFunc(webhook(client.ExternalGames)) http.HandleFunc(webhook(client.ExternalGames, client))
http.HandleFunc(webhook(client.ExternalGameSources)) http.HandleFunc(webhook(client.ExternalGameSources, client))
http.HandleFunc(webhook(client.Franchises)) http.HandleFunc(webhook(client.Franchises, client))
http.HandleFunc(webhook(client.GameEngineLogos)) http.HandleFunc(webhook(client.GameEngineLogos, client))
http.HandleFunc(webhook(client.GameEngines)) http.HandleFunc(webhook(client.GameEngines, client))
http.HandleFunc(webhook(client.GameLocalizations)) http.HandleFunc(webhook(client.GameLocalizations, client))
http.HandleFunc(webhook(client.GameModes)) http.HandleFunc(webhook(client.GameModes, client))
http.HandleFunc(webhook(client.GameReleaseFormats)) http.HandleFunc(webhook(client.GameReleaseFormats, client))
http.HandleFunc(webhook(client.Games)) http.HandleFunc(webhook(client.Games, client))
http.HandleFunc(webhook(client.GameStatuses)) http.HandleFunc(webhook(client.GameStatuses, client))
http.HandleFunc(webhook(client.GameTimeToBeats)) http.HandleFunc(webhook(client.GameTimeToBeats, client))
http.HandleFunc(webhook(client.GameTypes)) http.HandleFunc(webhook(client.GameTypes, client))
http.HandleFunc(webhook(client.GameVersionFeatures)) http.HandleFunc(webhook(client.GameVersionFeatures, client))
http.HandleFunc(webhook(client.GameVersionFeatureValues)) http.HandleFunc(webhook(client.GameVersionFeatureValues, client))
http.HandleFunc(webhook(client.GameVersions)) http.HandleFunc(webhook(client.GameVersions, client))
http.HandleFunc(webhook(client.GameVideos)) http.HandleFunc(webhook(client.GameVideos, client))
http.HandleFunc(webhook(client.Genres)) http.HandleFunc(webhook(client.Genres, client))
http.HandleFunc(webhook(client.InvolvedCompanies)) http.HandleFunc(webhook(client.InvolvedCompanies, client))
http.HandleFunc(webhook(client.Keywords)) http.HandleFunc(webhook(client.Keywords, client))
http.HandleFunc(webhook(client.Languages)) http.HandleFunc(webhook(client.Languages, client))
http.HandleFunc(webhook(client.LanguageSupports)) http.HandleFunc(webhook(client.LanguageSupports, client))
http.HandleFunc(webhook(client.LanguageSupportTypes)) http.HandleFunc(webhook(client.LanguageSupportTypes, client))
http.HandleFunc(webhook(client.MultiplayerModes)) http.HandleFunc(webhook(client.MultiplayerModes, client))
http.HandleFunc(webhook(client.NetworkTypes)) http.HandleFunc(webhook(client.NetworkTypes, client))
http.HandleFunc(webhook(client.PlatformFamilies)) http.HandleFunc(webhook(client.PlatformFamilies, client))
http.HandleFunc(webhook(client.PlatformLogos)) http.HandleFunc(webhook(client.PlatformLogos, client))
http.HandleFunc(webhook(client.Platforms)) http.HandleFunc(webhook(client.Platforms, client))
http.HandleFunc(webhook(client.PlatformTypes)) http.HandleFunc(webhook(client.PlatformTypes, client))
http.HandleFunc(webhook(client.PlatformVersionCompanies)) http.HandleFunc(webhook(client.PlatformVersionCompanies, client))
http.HandleFunc(webhook(client.PlatformVersionReleaseDates)) http.HandleFunc(webhook(client.PlatformVersionReleaseDates, client))
http.HandleFunc(webhook(client.PlatformVersions)) http.HandleFunc(webhook(client.PlatformVersions, client))
http.HandleFunc(webhook(client.PlatformWebsites)) http.HandleFunc(webhook(client.PlatformWebsites, client))
http.HandleFunc(webhook(client.PlayerPerspectives)) http.HandleFunc(webhook(client.PlayerPerspectives, client))
http.HandleFunc(webhook(client.PopularityTypes)) http.HandleFunc(webhook(client.PopularityTypes, client))
http.HandleFunc(webhook(client.Regions)) http.HandleFunc(webhook(client.Regions, client))
http.HandleFunc(webhook(client.ReleaseDateRegions)) http.HandleFunc(webhook(client.ReleaseDateRegions, client))
http.HandleFunc(webhook(client.ReleaseDates)) http.HandleFunc(webhook(client.ReleaseDates, client))
http.HandleFunc(webhook(client.ReleaseDateStatuses)) http.HandleFunc(webhook(client.ReleaseDateStatuses, client))
http.HandleFunc(webhook(client.Screenshots)) http.HandleFunc(webhook(client.Screenshots, client))
http.HandleFunc(webhook(client.Themes)) http.HandleFunc(webhook(client.Themes, client))
http.HandleFunc(webhook(client.Websites)) http.HandleFunc(webhook(client.Websites, client))
http.HandleFunc(webhook(client.WebsiteTypes)) http.HandleFunc(webhook(client.WebsiteTypes, client))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200) w.WriteHeader(200)
if _, err := w.Write([]byte("Hello World!")); err != nil { if _, err := w.Write([]byte("Hello World!")); err != nil {
@ -141,6 +141,7 @@ func StartWebhookServer(client *igdb.Client) {
func webhook[T any]( func webhook[T any](
e endpoint.EntityEndpoint[T], e endpoint.EntityEndpoint[T],
client *igdb.Client,
) (string, func(w http.ResponseWriter, r *http.Request)) { ) (string, func(w http.ResponseWriter, r *http.Request)) {
return fmt.Sprintf("/webhook/%s", e.GetEndpointName()), func(w http.ResponseWriter, r *http.Request) { return fmt.Sprintf("/webhook/%s", e.GetEndpointName()), func(w http.ResponseWriter, r *http.Request) {
secret := r.Header.Get("X-Secret") secret := r.Header.Get("X-Secret")
@ -173,7 +174,7 @@ func webhook[T any](
if _, ok := any(e).(*endpoint.Games); ok { if _, ok := any(e).(*endpoint.Games); ok {
game := any(item).(*pb.Game) game := any(item).(*pb.Game)
g, err := db.ConvertGame(game) g, err := db.ConvertGame(game, client)
if err != nil { if err != nil {
log.Printf("failed to convert game: %v", err) log.Printf("failed to convert game: %v", err)
} else { } else {
@ -199,7 +200,7 @@ func webhook[T any](
log.Printf("failed to get game: %v", err) log.Printf("failed to get game: %v", err)
goto END goto END
} }
g, err := db.ConvertGame(game) g, err := db.ConvertGame(game, client)
if err != nil { if err != nil {
log.Printf("failed to convert game: %v", err) log.Printf("failed to convert game: %v", err)
goto END goto END

View File

@ -125,6 +125,14 @@ func (m *MongoDB) createIndex() {
if err != nil { if err != nil {
log.Printf("failed to create index id for %s: %v", string(e), err) log.Printf("failed to create index id for %s: %v", string(e), err)
} }
_, err = m.Collections[e].Indexes().CreateOne(ctx, mongo.IndexModel{
Keys: bson.D{
{Key: "updated_at", Value: 1},
},
})
if err != nil {
log.Printf("failed to create index id for %s: %v", string(e), err)
}
} }
_, err := m.GameCollection.Indexes().CreateOne(ctx, mongo.IndexModel{ _, err := m.GameCollection.Indexes().CreateOne(ctx, mongo.IndexModel{
@ -276,3 +284,25 @@ func GetItemsPaginated[T any](e endpoint.Name, skip int64, limit int64) ([]*T, e
} }
return items, nil return items, nil
} }
func GetItemsSorted[T any](e endpoint.Name, limit int, sort bson.M) ([]*T, error) {
coll := GetInstance().Collections[e]
if coll == nil {
return nil, fmt.Errorf("collection not found")
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second+time.Duration(limit*200)*time.Millisecond)
defer cancel()
opts := options.Find().SetLimit(int64(limit)).SetSort(sort)
cursor, err := coll.Find(ctx, bson.M{}, opts)
if err != nil {
return nil, fmt.Errorf("failed to get items: %w", err)
}
var items []*T
err = cursor.All(ctx, &items)
if err != nil {
return nil, fmt.Errorf("failed to get items: %w", err)
}
return items, nil
}

View File

@ -7,6 +7,7 @@ import (
"igdb-database/model" "igdb-database/model"
"time" "time"
"github.com/bestnite/go-igdb"
"github.com/bestnite/go-igdb/endpoint" "github.com/bestnite/go-igdb/endpoint"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"go.mongodb.org/mongo-driver/v2/bson" "go.mongodb.org/mongo-driver/v2/bson"
@ -69,7 +70,11 @@ func SaveGames(games []*model.Game) error {
return nil return nil
} }
func ConvertGame(game *pb.Game) (*model.Game, error) { type IdGetter interface {
GetId() uint64
}
func ConvertGame(game *pb.Game, client *igdb.Client) (*model.Game, error) {
res := &model.Game{} res := &model.Game{}
if game == nil { if game == nil {
@ -86,6 +91,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(ageRatings) != len(ageRatingsIds) {
missingIds := make([]uint64, 0, len(ageRatingsIds)-len(ageRatings))
for _, id := range ageRatingsIds {
found := false
for _, item := range ageRatings {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
ageRatings, err = client.AgeRatings.GetByIDs(missingIds)
if err != nil {
return nil, err
}
ageRatings = append(ageRatings, ageRatings...)
err = SaveItems(endpoint.EPAgeRatings, ageRatings)
if err != nil {
return nil, err
}
}
res.AgeRatings = ageRatings res.AgeRatings = ageRatings
res.AggregatedRating = game.AggregatedRating res.AggregatedRating = game.AggregatedRating
@ -99,6 +128,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(alternativeNames) != len(alternativeNameIds) {
missingIds := make([]uint64, 0, len(alternativeNameIds)-len(alternativeNames))
for _, id := range alternativeNameIds {
found := false
for _, item := range alternativeNames {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
alternativeNames, err = client.AlternativeNames.GetByIDs(missingIds)
if err != nil {
return nil, err
}
alternativeNames = append(alternativeNames, alternativeNames...)
err = SaveItems(endpoint.EPAlternativeNames, alternativeNames)
if err != nil {
return nil, err
}
}
res.AlternativeNames = alternativeNames res.AlternativeNames = alternativeNames
ArtworkIds := make([]uint64, 0, len(game.Artworks)) ArtworkIds := make([]uint64, 0, len(game.Artworks))
@ -109,6 +162,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(artworks) != len(ArtworkIds) {
missingIds := make([]uint64, 0, len(ArtworkIds)-len(artworks))
for _, id := range ArtworkIds {
found := false
for _, item := range artworks {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
artworks, err = client.Artworks.GetByIDs(missingIds)
if err != nil {
return nil, err
}
artworks = append(artworks, artworks...)
err = SaveItems(endpoint.EPArtworks, artworks)
if err != nil {
return nil, err
}
}
res.Artworks = artworks res.Artworks = artworks
bundlesIds := make([]uint64, 0, len(game.Bundles)) bundlesIds := make([]uint64, 0, len(game.Bundles))
@ -120,8 +197,15 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if game.Cover != nil { if game.Cover != nil {
coverId := game.Cover.Id coverId := game.Cover.Id
cover, err := GetItemById[pb.Cover](endpoint.EPCovers, coverId) cover, err := GetItemById[pb.Cover](endpoint.EPCovers, coverId)
if err != nil && !errors.Is(err, mongo.ErrNoDocuments) { if err != nil {
return nil, err if errors.Is(err, mongo.ErrNoDocuments) {
cover, err = client.Covers.GetByID(coverId)
if err != nil {
return nil, err
}
} else {
return nil, err
}
} }
if cover != nil { if cover != nil {
res.Cover = cover res.Cover = cover
@ -150,6 +234,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(externalGames) != len(externalGameIds) {
missingIds := make([]uint64, 0, len(externalGameIds)-len(externalGames))
for _, id := range externalGameIds {
found := false
for _, item := range externalGames {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
externalGames, err = client.ExternalGames.GetByIDs(missingIds)
if err != nil {
return nil, err
}
externalGames = append(externalGames, externalGames...)
err = SaveItems(endpoint.EPExternalGames, externalGames)
if err != nil {
return nil, err
}
}
res.ExternalGames = externalGames res.ExternalGames = externalGames
res.FirstReleaseDate = game.FirstReleaseDate res.FirstReleaseDate = game.FirstReleaseDate
@ -159,8 +267,19 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if game.Franchise != nil { if game.Franchise != nil {
franchiseId := game.Franchise.Id franchiseId := game.Franchise.Id
franchise, err := GetItemById[pb.Franchise](endpoint.EPFranchises, franchiseId) franchise, err := GetItemById[pb.Franchise](endpoint.EPFranchises, franchiseId)
if err != nil && !errors.Is(err, mongo.ErrNoDocuments) { if err != nil {
return nil, err if errors.Is(err, mongo.ErrNoDocuments) {
franchise, err = client.Franchises.GetByID(franchiseId)
if err != nil {
return nil, err
}
err = SaveItem(endpoint.EPFranchises, franchise)
if err != nil {
return nil, err
}
} else {
return nil, err
}
} }
if franchise != nil { if franchise != nil {
res.Franchise = franchise res.Franchise = franchise
@ -175,6 +294,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(franchises) != len(franchiseIds) {
missingIds := make([]uint64, 0, len(franchiseIds)-len(franchises))
for _, id := range franchiseIds {
found := false
for _, item := range franchises {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
franchises, err = client.Franchises.GetByIDs(missingIds)
if err != nil {
return nil, err
}
franchises = append(franchises, franchises...)
err = SaveItems(endpoint.EPFranchises, franchises)
if err != nil {
return nil, err
}
}
res.Franchises = franchises res.Franchises = franchises
gameEngineIds := make([]uint64, 0, len(game.GameEngines)) gameEngineIds := make([]uint64, 0, len(game.GameEngines))
@ -185,6 +328,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(gameEngines) != len(gameEngineIds) {
missingIds := make([]uint64, 0, len(gameEngineIds)-len(gameEngines))
for _, id := range gameEngineIds {
found := false
for _, item := range gameEngines {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
gameEngines, err = client.GameEngines.GetByIDs(missingIds)
if err != nil {
return nil, err
}
gameEngines = append(gameEngines, gameEngines...)
err = SaveItems(endpoint.EPGameEngines, gameEngines)
if err != nil {
return nil, err
}
}
res.GameEngines = gameEngines res.GameEngines = gameEngines
gameModeIds := make([]uint64, 0, len(game.GameModes)) gameModeIds := make([]uint64, 0, len(game.GameModes))
@ -195,6 +362,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(gameModes) != len(gameModeIds) {
missingIds := make([]uint64, 0, len(gameModeIds)-len(gameModes))
for _, id := range gameModeIds {
found := false
for _, item := range gameModes {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
gameModes, err = client.GameModes.GetByIDs(missingIds)
if err != nil {
return nil, err
}
gameModes = append(gameModes, gameModes...)
err = SaveItems(endpoint.EPGameModes, gameModes)
if err != nil {
return nil, err
}
}
res.GameModes = gameModes res.GameModes = gameModes
genreIds := make([]uint64, 0, len(game.Genres)) genreIds := make([]uint64, 0, len(game.Genres))
@ -205,6 +396,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(genres) != len(genreIds) {
missingIds := make([]uint64, 0, len(genreIds)-len(genres))
for _, id := range genreIds {
found := false
for _, item := range genres {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
genres, err = client.Genres.GetByIDs(missingIds)
if err != nil {
return nil, err
}
genres = append(genres, genres...)
err = SaveItems(endpoint.EPGenres, genres)
if err != nil {
return nil, err
}
}
res.Genres = genres res.Genres = genres
res.Hypes = game.Hypes res.Hypes = game.Hypes
@ -217,6 +432,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(involvedCompanies) != len(involvedCompanyIds) {
missingIds := make([]uint64, 0, len(involvedCompanyIds)-len(involvedCompanies))
for _, id := range involvedCompanyIds {
found := false
for _, item := range involvedCompanies {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
involvedCompanies, err = client.InvolvedCompanies.GetByIDs(missingIds)
if err != nil {
return nil, err
}
involvedCompanies = append(involvedCompanies, involvedCompanies...)
err = SaveItems(endpoint.EPInvolvedCompanies, involvedCompanies)
if err != nil {
return nil, err
}
}
res.InvolvedCompanies = involvedCompanies res.InvolvedCompanies = involvedCompanies
keywordIds := make([]uint64, 0, len(game.Keywords)) keywordIds := make([]uint64, 0, len(game.Keywords))
@ -227,6 +466,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(keyword) != len(keywordIds) {
missingIds := make([]uint64, 0, len(keywordIds)-len(keyword))
for _, id := range keywordIds {
found := false
for _, item := range keyword {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
keyword, err = client.Keywords.GetByIDs(missingIds)
if err != nil {
return nil, err
}
keyword = append(keyword, keyword...)
err = SaveItems(endpoint.EPKeywords, keyword)
if err != nil {
return nil, err
}
}
res.Keywords = keyword res.Keywords = keyword
multiplayerModeIds := make([]uint64, 0, len(game.MultiplayerModes)) multiplayerModeIds := make([]uint64, 0, len(game.MultiplayerModes))
@ -237,6 +500,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(multiplayerModes) != len(multiplayerModeIds) {
missingIds := make([]uint64, 0, len(multiplayerModeIds)-len(multiplayerModes))
for _, id := range multiplayerModeIds {
found := false
for _, item := range multiplayerModes {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
multiplayerModes, err = client.MultiplayerModes.GetByIDs(missingIds)
if err != nil {
return nil, err
}
multiplayerModes = append(multiplayerModes, multiplayerModes...)
err = SaveItems(endpoint.EPMultiplayerModes, multiplayerModes)
if err != nil {
return nil, err
}
}
res.MultiplayerModes = multiplayerModes res.MultiplayerModes = multiplayerModes
res.Name = game.Name res.Name = game.Name
@ -253,6 +540,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(platforms) != len(platformIds) {
missingIds := make([]uint64, 0, len(platformIds)-len(platforms))
for _, id := range platformIds {
found := false
for _, item := range platforms {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
platforms, err = client.Platforms.GetByIDs(missingIds)
if err != nil {
return nil, err
}
platforms = append(platforms, platforms...)
err = SaveItems(endpoint.EPPlatforms, platforms)
if err != nil {
return nil, err
}
}
res.Platforms = platforms res.Platforms = platforms
playerPerspectiveIds := make([]uint64, 0, len(game.PlayerPerspectives)) playerPerspectiveIds := make([]uint64, 0, len(game.PlayerPerspectives))
@ -263,6 +574,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(playerPerspectives) != len(playerPerspectiveIds) {
missingIds := make([]uint64, 0, len(playerPerspectiveIds)-len(playerPerspectives))
for _, id := range playerPerspectiveIds {
found := false
for _, item := range playerPerspectives {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
playerPerspectives, err = client.PlayerPerspectives.GetByIDs(missingIds)
if err != nil {
return nil, err
}
playerPerspectives = append(playerPerspectives, playerPerspectives...)
err = SaveItems(endpoint.EPPlayerPerspectives, playerPerspectives)
if err != nil {
return nil, err
}
}
res.PlayerPerspectives = playerPerspectives res.PlayerPerspectives = playerPerspectives
res.Rating = game.Rating res.Rating = game.Rating
@ -276,6 +611,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(releaseDates) != len(releaseDateIds) {
missingIds := make([]uint64, 0, len(releaseDateIds)-len(releaseDates))
for _, id := range releaseDateIds {
found := false
for _, item := range releaseDates {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
releaseDates, err = client.ReleaseDates.GetByIDs(missingIds)
if err != nil {
return nil, err
}
releaseDates = append(releaseDates, releaseDates...)
err = SaveItems(endpoint.EPReleaseDates, releaseDates)
if err != nil {
return nil, err
}
}
res.ReleaseDates = releaseDates res.ReleaseDates = releaseDates
screenshotIds := make([]uint64, 0, len(game.Screenshots)) screenshotIds := make([]uint64, 0, len(game.Screenshots))
@ -286,6 +645,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(screenshots) != len(screenshotIds) {
missingIds := make([]uint64, 0, len(screenshotIds)-len(screenshots))
for _, id := range screenshotIds {
found := false
for _, item := range screenshots {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
screenshots, err = client.Screenshots.GetByIDs(missingIds)
if err != nil {
return nil, err
}
screenshots = append(screenshots, screenshots...)
err = SaveItems(endpoint.EPScreenshots, screenshots)
if err != nil {
return nil, err
}
}
res.Screenshots = screenshots res.Screenshots = screenshots
similarGamesIds := make([]uint64, 0, len(game.SimilarGames)) similarGamesIds := make([]uint64, 0, len(game.SimilarGames))
@ -315,6 +698,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(themes) != len(themeIds) {
missingIds := make([]uint64, 0, len(themeIds)-len(themes))
for _, id := range themeIds {
found := false
for _, item := range themes {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
themes, err = client.Themes.GetByIDs(missingIds)
if err != nil {
return nil, err
}
themes = append(themes, themes...)
err = SaveItems(endpoint.EPThemes, themes)
if err != nil {
return nil, err
}
}
res.Themes = themes res.Themes = themes
res.TotalRating = game.TotalRating res.TotalRating = game.TotalRating
@ -338,6 +745,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(videos) != len(videoIds) {
missingIds := make([]uint64, 0, len(videoIds)-len(videos))
for _, id := range videoIds {
found := false
for _, item := range videos {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
videos, err = client.GameVideos.GetByIDs(missingIds)
if err != nil {
return nil, err
}
videos = append(videos, videos...)
err = SaveItems(endpoint.EPGameVideos, videos)
if err != nil {
return nil, err
}
}
res.Videos = videos res.Videos = videos
websiteIds := make([]uint64, 0, len(game.Websites)) websiteIds := make([]uint64, 0, len(game.Websites))
@ -348,6 +779,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(websites) != len(websiteIds) {
missingIds := make([]uint64, 0, len(websiteIds)-len(websites))
for _, id := range websiteIds {
found := false
for _, item := range websites {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
websites, err = client.Websites.GetByIDs(missingIds)
if err != nil {
return nil, err
}
websites = append(websites, websites...)
err = SaveItems(endpoint.EPWebsites, websites)
if err != nil {
return nil, err
}
}
res.Websites = websites res.Websites = websites
remakesIds := make([]uint64, 0, len(game.Remakes)) remakesIds := make([]uint64, 0, len(game.Remakes))
@ -388,6 +843,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(languageSupports) != len(languageSupportIds) {
missingIds := make([]uint64, 0, len(languageSupportIds)-len(languageSupports))
for _, id := range languageSupportIds {
found := false
for _, item := range languageSupports {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
languageSupports, err = client.LanguageSupports.GetByIDs(missingIds)
if err != nil {
return nil, err
}
languageSupports = append(languageSupports, languageSupports...)
err = SaveItems(endpoint.EPLanguageSupports, languageSupports)
if err != nil {
return nil, err
}
}
res.LanguageSupports = languageSupports res.LanguageSupports = languageSupports
gameLocalizationIds := make([]uint64, 0, len(game.GameLocalizations)) gameLocalizationIds := make([]uint64, 0, len(game.GameLocalizations))
@ -398,6 +877,30 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(gameLocalizations) != len(gameLocalizationIds) {
missingIds := make([]uint64, 0, len(gameLocalizationIds)-len(gameLocalizations))
for _, id := range gameLocalizationIds {
found := false
for _, item := range gameLocalizations {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
gameLocalizations, err = client.GameLocalizations.GetByIDs(missingIds)
if err != nil {
return nil, err
}
gameLocalizations = append(gameLocalizations, gameLocalizations...)
err = SaveItems(endpoint.EPGameLocalizations, gameLocalizations)
if err != nil {
return nil, err
}
}
res.GameLocalizations = gameLocalizations res.GameLocalizations = gameLocalizations
collectionIds := make([]uint64, 0, len(game.Collections)) collectionIds := make([]uint64, 0, len(game.Collections))
@ -408,10 +911,34 @@ func ConvertGame(game *pb.Game) (*model.Game, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(collections) != len(collectionIds) {
missingIds := make([]uint64, 0, len(collectionIds)-len(collections))
for _, id := range collectionIds {
found := false
for _, item := range collections {
if item.GetId() == id {
found = true
break
}
}
if !found {
missingIds = append(missingIds, id)
}
}
collections, err = client.Collections.GetByIDs(missingIds)
if err != nil {
return nil, err
}
collections = append(collections, collections...)
err = SaveItems(endpoint.EPCollections, collections)
if err != nil {
return nil, err
}
}
res.Collections = collections res.Collections = collections
res.GameStatus = nil res.GameStatus = game.GameStatus
res.GameType = nil res.GameType = game.GameType
res.AllNames = make([]string, 0, len(alternativeNames)+1) res.AllNames = make([]string, 0, len(alternativeNames)+1)
res.AllNames = append(res.AllNames, game.Name) res.AllNames = append(res.AllNames, game.Name)

18
go.mod
View File

@ -3,7 +3,7 @@ module igdb-database
go 1.24.1 go 1.24.1
require ( require (
github.com/bestnite/go-igdb v0.0.12 github.com/bestnite/go-igdb v0.0.13
go.mongodb.org/mongo-driver/v2 v2.1.0 go.mongodb.org/mongo-driver/v2 v2.1.0
google.golang.org/protobuf v1.36.6 google.golang.org/protobuf v1.36.6
) )
@ -11,24 +11,24 @@ require (
require ( require (
github.com/Danny-Dasilva/CycleTLS/cycletls v1.0.26 // indirect github.com/Danny-Dasilva/CycleTLS/cycletls v1.0.26 // indirect
github.com/Danny-Dasilva/fhttp v0.0.0-20240217042913-eeeb0b347ce1 // indirect github.com/Danny-Dasilva/fhttp v0.0.0-20240217042913-eeeb0b347ce1 // indirect
github.com/PuerkitoBio/goquery v1.10.2 // indirect github.com/PuerkitoBio/goquery v1.10.3 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect github.com/andybalholm/brotli v1.1.1 // indirect
github.com/andybalholm/cascadia v1.3.3 // indirect github.com/andybalholm/cascadia v1.3.3 // indirect
github.com/bestnite/go-flaresolverr v0.0.0-20250404141941-4644c2e66727 // indirect github.com/bestnite/go-flaresolverr v0.0.0-20250404141941-4644c2e66727 // indirect
github.com/cloudflare/circl v1.6.0 // indirect github.com/cloudflare/circl v1.6.1 // indirect
github.com/go-resty/resty/v2 v2.16.5 // indirect github.com/go-resty/resty/v2 v2.16.5 // indirect
github.com/golang/snappy v1.0.0 // indirect github.com/golang/snappy v1.0.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect github.com/gorilla/websocket v1.5.3 // indirect
github.com/klauspost/compress v1.18.0 // indirect github.com/klauspost/compress v1.18.0 // indirect
github.com/refraction-networking/utls v1.6.7 // indirect github.com/refraction-networking/utls v1.7.3 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
golang.org/x/crypto v0.37.0 // indirect golang.org/x/crypto v0.38.0 // indirect
golang.org/x/net v0.39.0 // indirect golang.org/x/net v0.40.0 // indirect
golang.org/x/sync v0.13.0 // indirect golang.org/x/sync v0.14.0 // indirect
golang.org/x/sys v0.32.0 // indirect golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.24.0 // indirect golang.org/x/text v0.25.0 // indirect
h12.io/socks v1.0.3 // indirect h12.io/socks v1.0.3 // indirect
) )

40
go.sum
View File

@ -12,8 +12,8 @@ github.com/Danny-Dasilva/CycleTLS/cycletls v1.0.26 h1:6fexoGmvzoXMSk14BZ0AirapVm
github.com/Danny-Dasilva/CycleTLS/cycletls v1.0.26/go.mod h1:QFi/EVO7qqru3Ftxz1LR+96jIc91Tifv0DnskF/gWQ8= github.com/Danny-Dasilva/CycleTLS/cycletls v1.0.26/go.mod h1:QFi/EVO7qqru3Ftxz1LR+96jIc91Tifv0DnskF/gWQ8=
github.com/Danny-Dasilva/fhttp v0.0.0-20240217042913-eeeb0b347ce1 h1:/lqhaiz7xdPr6kuaW1tQ/8DdpWdxkdyd9W/6EHz4oRw= github.com/Danny-Dasilva/fhttp v0.0.0-20240217042913-eeeb0b347ce1 h1:/lqhaiz7xdPr6kuaW1tQ/8DdpWdxkdyd9W/6EHz4oRw=
github.com/Danny-Dasilva/fhttp v0.0.0-20240217042913-eeeb0b347ce1/go.mod h1:Hvab/V/YKCDXsEpKYKHjAXH5IFOmoq9FsfxjztEqvDc= github.com/Danny-Dasilva/fhttp v0.0.0-20240217042913-eeeb0b347ce1/go.mod h1:Hvab/V/YKCDXsEpKYKHjAXH5IFOmoq9FsfxjztEqvDc=
github.com/PuerkitoBio/goquery v1.10.2 h1:7fh2BdHcG6VFZsK7toXBT/Bh1z5Wmy8Q9MV9HqT2AM8= github.com/PuerkitoBio/goquery v1.10.3 h1:pFYcNSqHxBD06Fpj/KsbStFRsgRATgnf3LeXiUkhzPo=
github.com/PuerkitoBio/goquery v1.10.2/go.mod h1:0guWGjcLu9AYC7C1GHnpysHy056u9aEkUHwhdnePMCU= github.com/PuerkitoBio/goquery v1.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7iK7iLNd4RH4Y=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
@ -23,10 +23,8 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYU
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/bestnite/go-flaresolverr v0.0.0-20250404141941-4644c2e66727 h1:F1fNb9j7wgPXa54SWAIYn1l8NJTg74Qx3EJ8qmys6FY= github.com/bestnite/go-flaresolverr v0.0.0-20250404141941-4644c2e66727 h1:F1fNb9j7wgPXa54SWAIYn1l8NJTg74Qx3EJ8qmys6FY=
github.com/bestnite/go-flaresolverr v0.0.0-20250404141941-4644c2e66727/go.mod h1:LX2oPIfG4LnUtQ7FAWV727IXuODZVbzRwG/7t2KdMNo= github.com/bestnite/go-flaresolverr v0.0.0-20250404141941-4644c2e66727/go.mod h1:LX2oPIfG4LnUtQ7FAWV727IXuODZVbzRwG/7t2KdMNo=
github.com/bestnite/go-igdb v0.0.11 h1:DIG3NjTpRfpIDIbTsbOuMWI/Y7IZRUNu/WaOaPZdcKg= github.com/bestnite/go-igdb v0.0.13 h1:4E1q1zK+wbcPs0LOrVlJmIIjW4+gLvqDvUxcF95lKJ4=
github.com/bestnite/go-igdb v0.0.11/go.mod h1:HBPwYCgSVd7oaiLWJVV72UpqsmIYjUmaIvGmuFk3CwY= github.com/bestnite/go-igdb v0.0.13/go.mod h1:HBPwYCgSVd7oaiLWJVV72UpqsmIYjUmaIvGmuFk3CwY=
github.com/bestnite/go-igdb v0.0.12 h1:zWTcJTYeV/j5vlNXoyadnOEsOJQfYIh+iLq1FurN0G4=
github.com/bestnite/go-igdb v0.0.12/go.mod h1:HBPwYCgSVd7oaiLWJVV72UpqsmIYjUmaIvGmuFk3CwY=
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
@ -35,8 +33,8 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cloudflare/circl v1.6.0 h1:cr5JKic4HI+LkINy2lg3W2jF8sHCVTBncJr5gIIq7qk= github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
github.com/cloudflare/circl v1.6.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@ -165,8 +163,8 @@ github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1
github.com/quic-go/qtls-go1-20 v0.3.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= github.com/quic-go/qtls-go1-20 v0.3.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
github.com/quic-go/quic-go v0.37.4/go.mod h1:YsbH1r4mSHPJcLF4k4zruUkLBqctEMBDR6VPvcYjIsU= github.com/quic-go/quic-go v0.37.4/go.mod h1:YsbH1r4mSHPJcLF4k4zruUkLBqctEMBDR6VPvcYjIsU=
github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw= github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw=
github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM= github.com/refraction-networking/utls v1.7.3 h1:L0WRhHY7Oq1T0zkdzVZMR6zWZv+sXbHB9zcuvsAEqCo=
github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/refraction-networking/utls v1.7.3/go.mod h1:TUhh27RHMGtQvjQq+RyO11P6ZNQNBb3N0v7wsEjKAIQ=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY=
@ -233,8 +231,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/exp v0.0.0-20221205204356-47842c84f3db/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@ -284,10 +282,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY=
golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@ -307,8 +303,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@ -345,8 +341,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@ -379,8 +375,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=

View File

@ -24,6 +24,7 @@ var (
) )
func main() { func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
flag.Parse() flag.Parse()
client := igdb.New(config.C().Twitch.ClientID, config.C().Twitch.ClientSecret) client := igdb.New(config.C().Twitch.ClientID, config.C().Twitch.ClientSecret)
@ -36,7 +37,7 @@ func main() {
if *enableAggregate || *enableReAggregate { if *enableAggregate || *enableReAggregate {
log.Printf("aggregating games") log.Printf("aggregating games")
aggregateGames() aggregateGames(client)
log.Printf("games aggregated") log.Printf("games aggregated")
} }
@ -46,7 +47,7 @@ func main() {
} }
} }
func aggregateGames() { func aggregateGames(client *igdb.Client) {
total, err := db.EstimatedDocumentCount(endpoint.EPGames) total, err := db.EstimatedDocumentCount(endpoint.EPGames)
if err != nil { if err != nil {
log.Fatalf("failed to count games: %v", err) log.Fatalf("failed to count games: %v", err)
@ -89,7 +90,7 @@ func aggregateGames() {
continue continue
} }
game, err := db.ConvertGame(item) game, err := db.ConvertGame(item, client)
if err != nil { if err != nil {
log.Fatalf("failed to convert game: %v", err) log.Fatalf("failed to convert game: %v", err)
} }