Added recommendations view to the UI

This commit is contained in:
2018-02-24 15:35:34 +01:00
parent b9f8cfc79e
commit d4d7294f4e
3 changed files with 15 additions and 15 deletions

View File

@ -1,13 +1,13 @@
package recommended
import (
"fmt"
"net/http"
"sort"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const (
@ -17,14 +17,15 @@ const (
// Anime shows a list of recommended anime.
func Anime(ctx *aero.Context) string {
user := utils.GetUser(ctx)
nick := ctx.Get("nick")
user, err := arn.GetUserByNick(nick)
viewUser, err := arn.GetUserByNick(nick)
if err != nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in", err)
}
animeList := user.AnimeList()
animeList := viewUser.AnimeList()
genreItems := animeList.Genres()
genreAffinity := map[string]float64{}
worstGenres := []string{}
@ -57,8 +58,6 @@ func Anime(ctx *aero.Context) string {
worstGenres = worstGenres[:worstGenreCount]
}
fmt.Println(worstGenres)
// Get all anime
recommendations := arn.AllAnime()
@ -121,5 +120,5 @@ func Anime(ctx *aero.Context) string {
recommendations = recommendations[:maxRecommendations]
}
return ctx.HTML(components.RecommendedAnime(recommendations, user))
return ctx.HTML(components.RecommendedAnime(recommendations, worstGenres, viewUser, user))
}