From cbdf8c0059f7146e2cb4d70f9f78e14e28f16ea1 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 21 Jun 2017 00:34:18 +0200 Subject: [PATCH] Added Japanese titles to search index --- jobs/search-index/main.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/jobs/search-index/main.go b/jobs/search-index/main.go index e81b7134..214d4a2e 100644 --- a/jobs/search-index/main.go +++ b/jobs/search-index/main.go @@ -1,14 +1,20 @@ package main import ( + "fmt" "strings" "github.com/aerogo/aero" "github.com/animenotifier/arn" + "github.com/fatih/color" ) func main() { + color.Yellow("Updating search index") + aero.Parallel(updateAnimeIndex, updateUserIndex) + + color.Green("Finished.") } func updateAnimeIndex() { @@ -22,9 +28,17 @@ func updateAnimeIndex() { } for anime := range animeStream { - animeSearchIndex.TextToID[strings.ToLower(anime.Title.Canonical)] = anime.ID + if anime.Title.Canonical != "" { + animeSearchIndex.TextToID[strings.ToLower(anime.Title.Canonical)] = anime.ID + } + + if anime.Title.Japanese != "" { + animeSearchIndex.TextToID[anime.Title.Japanese] = anime.ID + } } + fmt.Println(len(animeSearchIndex.TextToID), "anime titles") + // Save in database err = arn.DB.Set("SearchIndex", "Anime", animeSearchIndex) @@ -44,9 +58,13 @@ func updateUserIndex() { } for user := range userStream { - userSearchIndex.TextToID[strings.ToLower(user.Nick)] = user.ID + if user.IsActive() && user.Nick != "" { + userSearchIndex.TextToID[strings.ToLower(user.Nick)] = user.ID + } } + fmt.Println(len(userSearchIndex.TextToID), "user names") + // Save in database err = arn.DB.Set("SearchIndex", "User", userSearchIndex)