Improved anime list comparison

This commit is contained in:
Eduard Urbach 2017-10-21 19:23:40 +02:00
parent 6c0f8a6318
commit fd03d31187
3 changed files with 23 additions and 4 deletions

View File

@ -30,12 +30,16 @@ func AnimeList(ctx *aero.Context) string {
} }
comparisons := []*utils.Comparison{} comparisons := []*utils.Comparison{}
countA := 0
countB := 0
for _, item := range a.AnimeList().Items { for _, item := range a.AnimeList().Items {
if item.Status == arn.AnimeListStatusPlanned { if item.Status == arn.AnimeListStatusPlanned {
continue continue
} }
countA++
comparisons = append(comparisons, &utils.Comparison{ comparisons = append(comparisons, &utils.Comparison{
Anime: item.Anime(), Anime: item.Anime(),
ItemA: item, ItemA: item,
@ -44,7 +48,13 @@ func AnimeList(ctx *aero.Context) string {
} }
for _, item := range b.AnimeList().Items { for _, item := range b.AnimeList().Items {
if Contains(comparisons, item.AnimeID) || item.Status == arn.AnimeListStatusPlanned { if item.Status == arn.AnimeListStatusPlanned {
continue
}
countB++
if Contains(comparisons, item.AnimeID) {
continue continue
} }
@ -59,7 +69,7 @@ func AnimeList(ctx *aero.Context) string {
return comparisons[i].Anime.Popularity.Total() > comparisons[j].Anime.Popularity.Total() return comparisons[i].Anime.Popularity.Total() > comparisons[j].Anime.Popularity.Total()
}) })
return ctx.HTML(components.CompareAnimeList(a, b, comparisons, user)) return ctx.HTML(components.CompareAnimeList(a, b, countA, countB, comparisons, user))
} }
// Contains ... // Contains ...

View File

@ -1,5 +1,7 @@
component CompareAnimeList(a *arn.User, b *arn.User, comparisons []*utils.Comparison, user *arn.User) component CompareAnimeList(a *arn.User, b *arn.User, countA int, countB int, comparisons []*utils.Comparison, user *arn.User)
h1= "Anime list comparison between " + a.Nick + " and " + b.Nick h1 Anime list comparison
p.comparison-info= a.Nick + "'s list contains " + strconv.Itoa(countA) + " anime and " + b.Nick + "'s list contains " + strconv.Itoa(countB) + " anime."
table.anime-list table.anime-list
thead thead

View File

@ -1,3 +1,10 @@
.comparison-info
text-align center
font-size 0.9rem
opacity 0.5
margin-top 0
margin-bottom content-padding
.comparison .comparison
width 100px width 100px
text-align center text-align center