From 74daef0df7f8ac830126102ef4dd8995c44af1cc Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 4 Apr 2018 15:21:52 +0200 Subject: [PATCH] Use generic AnimeFinder --- jobs/sync-characters/sync-characters.go | 10 ++++++---- pages/editor/kitsu.go | 2 +- pages/listimport/listimportkitsu/kitsu.go | 2 +- pages/listimport/listimportmyanimelist/myanimelist.go | 4 ++-- patches/import-kitsu-mappings/import-kitsu-mappings.go | 2 +- patches/kitsu-anilist/kitsu-anilist.go | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/jobs/sync-characters/sync-characters.go b/jobs/sync-characters/sync-characters.go index 18043e59..d6173324 100644 --- a/jobs/sync-characters/sync-characters.go +++ b/jobs/sync-characters/sync-characters.go @@ -33,10 +33,12 @@ func main() { }, Description: kitsuCharacter.Attributes.Description, Attributes: []*arn.CharacterAttribute{}, - Mappings: []*arn.Mapping{ - &arn.Mapping{ - Service: "kitsu/character", - ServiceID: kitsuCharacter.ID, + HasMappings: arn.HasMappings{ + Mappings: []*arn.Mapping{ + &arn.Mapping{ + Service: "kitsu/character", + ServiceID: kitsuCharacter.ID, + }, }, }, } diff --git a/pages/editor/kitsu.go b/pages/editor/kitsu.go index 960cc0d2..e93c6b02 100644 --- a/pages/editor/kitsu.go +++ b/pages/editor/kitsu.go @@ -13,7 +13,7 @@ import ( // NewKitsuAnime ... func NewKitsuAnime(ctx *aero.Context) string { user := utils.GetUser(ctx) - finder := arn.NewKitsuFinder() + finder := arn.NewAnimeFinder("kitsu/anime") animes := arn.FilterKitsuAnime(func(anime *kitsu.Anime) bool { return finder.GetAnime(anime.ID) == nil diff --git a/pages/listimport/listimportkitsu/kitsu.go b/pages/listimport/listimportkitsu/kitsu.go index 213b26fb..20f6ec72 100644 --- a/pages/listimport/listimportkitsu/kitsu.go +++ b/pages/listimport/listimportkitsu/kitsu.go @@ -112,7 +112,7 @@ func getMatches(ctx *aero.Context) ([]*arn.KitsuMatch, string) { // findAllMatches returns all matches for the anime inside an anilist anime list. func findAllMatches(library chan *kitsu.LibraryEntry) []*arn.KitsuMatch { - finder := arn.NewKitsuFinder() + finder := arn.NewAnimeFinder("kitsu/anime") matches := []*arn.KitsuMatch{} for item := range library { diff --git a/pages/listimport/listimportmyanimelist/myanimelist.go b/pages/listimport/listimportmyanimelist/myanimelist.go index 19ab9792..6f025c26 100644 --- a/pages/listimport/listimportmyanimelist/myanimelist.go +++ b/pages/listimport/listimportmyanimelist/myanimelist.go @@ -107,13 +107,13 @@ func getMatches(ctx *aero.Context) ([]*arn.MyAnimeListMatch, string) { // findAllMatches returns all matches for the anime inside an anilist anime list. func findAllMatches(animeList *mal.AnimeList) []*arn.MyAnimeListMatch { - allAnime := arn.AllAnime() + finder := arn.NewAnimeFinder("myanimelist/anime") matches := []*arn.MyAnimeListMatch{} for _, item := range animeList.Items { matches = append(matches, &arn.MyAnimeListMatch{ MyAnimeListItem: item, - ARNAnime: arn.FindMyAnimeListAnime(item.AnimeID, allAnime), + ARNAnime: finder.GetAnime(item.AnimeID), }) } diff --git a/patches/import-kitsu-mappings/import-kitsu-mappings.go b/patches/import-kitsu-mappings/import-kitsu-mappings.go index 726d5198..a955d523 100644 --- a/patches/import-kitsu-mappings/import-kitsu-mappings.go +++ b/patches/import-kitsu-mappings/import-kitsu-mappings.go @@ -13,7 +13,7 @@ func main() { defer color.Green("Finished.") defer arn.Node.Close() - finder := arn.NewKitsuFinder() + finder := arn.NewAnimeFinder("kitsu/anime") for mapping := range arn.StreamKitsuMappings() { if mapping.Relationships.Item.Data.Type != "anime" { diff --git a/patches/kitsu-anilist/kitsu-anilist.go b/patches/kitsu-anilist/kitsu-anilist.go index a2ad758c..550b99e9 100644 --- a/patches/kitsu-anilist/kitsu-anilist.go +++ b/patches/kitsu-anilist/kitsu-anilist.go @@ -16,7 +16,7 @@ func main() { added := 0 conflicted := 0 - finder := arn.NewKitsuFinder() + finder := arn.NewAnimeFinder("kitsu/anime") for mapping := range arn.StreamKitsuMappings() { if mapping.Relationships.Item.Data.Type != "anime" {