Added Japanese titles to search index

This commit is contained in:
Eduard Urbach 2017-06-21 00:34:18 +02:00
parent b9b92beb23
commit cbdf8c0059

View File

@ -1,14 +1,20 @@
package main package main
import ( import (
"fmt"
"strings" "strings"
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
"github.com/fatih/color"
) )
func main() { func main() {
color.Yellow("Updating search index")
aero.Parallel(updateAnimeIndex, updateUserIndex) aero.Parallel(updateAnimeIndex, updateUserIndex)
color.Green("Finished.")
} }
func updateAnimeIndex() { func updateAnimeIndex() {
@ -22,9 +28,17 @@ func updateAnimeIndex() {
} }
for anime := range animeStream { for anime := range animeStream {
if anime.Title.Canonical != "" {
animeSearchIndex.TextToID[strings.ToLower(anime.Title.Canonical)] = anime.ID 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 // Save in database
err = arn.DB.Set("SearchIndex", "Anime", animeSearchIndex) err = arn.DB.Set("SearchIndex", "Anime", animeSearchIndex)
@ -44,8 +58,12 @@ func updateUserIndex() {
} }
for user := range userStream { for user := range userStream {
if user.IsActive() && user.Nick != "" {
userSearchIndex.TextToID[strings.ToLower(user.Nick)] = user.ID userSearchIndex.TextToID[strings.ToLower(user.Nick)] = user.ID
} }
}
fmt.Println(len(userSearchIndex.TextToID), "user names")
// Save in database // Save in database
err = arn.DB.Set("SearchIndex", "User", userSearchIndex) err = arn.DB.Set("SearchIndex", "User", userSearchIndex)