Added user lists by country

This commit is contained in:
2018-11-06 20:20:19 +09:00
parent 57297c7de2
commit de8fec3114
5 changed files with 30 additions and 18 deletions

View File

@ -2,6 +2,7 @@ package users
import (
"sort"
"strings"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
@ -15,23 +16,7 @@ func Active(ctx *aero.Context) string {
return user.HasAvatar() && user.HasNick() && user.IsActive()
})
followCount := arn.UserFollowerCountMap()
sort.Slice(users, func(i, j int) bool {
if users[i].HasAvatar() != users[j].HasAvatar() {
return users[i].HasAvatar()
}
followersA := followCount[users[i].ID]
followersB := followCount[users[j].ID]
if followersA == followersB {
return users[i].Nick < users[j].Nick
}
return followersA > followersB
})
arn.SortUsersFollowers(users)
return ctx.HTML(components.Users(users, ctx.URI()))
}
@ -171,6 +156,18 @@ func FFXIV(ctx *aero.Context) string {
return ctx.HTML(components.FinalFantasyXIVRankingList(users, ctx.URI()))
}
// ByCountry ...
func ByCountry(ctx *aero.Context) string {
countryName := ctx.Get("country")
users := arn.FilterUsers(func(user *arn.User) bool {
return strings.ToLower(user.Location.CountryName) == countryName && user.Settings().Privacy.ShowLocation && user.HasAvatar() && user.HasNick() && user.IsActive()
})
arn.SortUsersFollowers(users)
return ctx.HTML(components.UsersByCountry(users, countryName))
}
// Staff ...
func Staff(ctx *aero.Context) string {
users := arn.FilterUsers(func(user *arn.User) bool {

View File

@ -6,6 +6,16 @@ component Users(users []*arn.User, url string)
each user in users
Avatar(user)
component UsersByCountry(users []*arn.User, countryName string)
if len(users) == 0
p.no-data.mountable= "Seems like there are no users in " + stringutils.Capitalize(countryName)
else
h1= "Users in " + users[0].Location.CountryName
.user-avatars.mountable
each user in users
Avatar(user)
component ProUsers(users []*arn.User, url string)
h1.page-title Supporters
UsersTabs(url)