64 lines
1.3 KiB
Go
Raw Normal View History

2016-12-06 03:36:31 +00:00
package users
import (
2017-10-28 01:53:12 +00:00
"sort"
2017-06-10 00:19:31 +00:00
2016-12-06 03:36:31 +00:00
"github.com/aerogo/aero"
2017-06-10 00:19:31 +00:00
"github.com/animenotifier/arn"
2016-12-06 03:36:31 +00:00
"github.com/animenotifier/notify.moe/components"
)
2017-07-19 11:08:12 +00:00
// Active ...
func Active(ctx *aero.Context) string {
2017-10-27 07:11:56 +00:00
users := arn.FilterUsers(func(user *arn.User) bool {
return user.IsActive() && user.HasAvatar()
})
2017-07-19 11:08:12 +00:00
2017-11-03 08:34:21 +00:00
sort.Slice(users, func(i, j int) bool {
return len(users[i].AnimeList().Watching().Items) > len(users[j].AnimeList().Watching().Items)
})
// arn.SortUsersLastSeen(users)
2017-07-19 11:08:12 +00:00
return ctx.HTML(components.Users(users))
}
// Osu ...
func Osu(ctx *aero.Context) string {
2017-10-28 01:53:12 +00:00
users := arn.FilterUsers(func(user *arn.User) bool {
return user.IsActive() && user.HasAvatar() && user.Accounts.Osu.PP > 0
})
2017-07-19 11:08:12 +00:00
2017-10-28 01:53:12 +00:00
// Sort by pp
sort.Slice(users, func(i, j int) bool {
return users[i].Accounts.Osu.PP > users[j].Accounts.Osu.PP
})
2017-07-19 11:08:12 +00:00
2017-10-07 08:52:59 +00:00
if len(users) > 50 {
users = users[:50]
}
return ctx.HTML(components.OsuRankingList(users))
2017-07-19 11:08:12 +00:00
}
// Staff ...
func Staff(ctx *aero.Context) string {
2017-10-28 01:53:12 +00:00
users := arn.FilterUsers(func(user *arn.User) bool {
return user.IsActive() && user.HasAvatar() && user.Role != ""
})
2017-07-19 11:08:12 +00:00
2017-10-28 01:53:12 +00:00
sort.Slice(users, func(i, j int) bool {
if users[i].Role == "" {
return false
}
if users[j].Role == "" {
return true
}
return users[i].Role == "admin"
})
2017-07-19 11:08:12 +00:00
return ctx.HTML(components.Users(users))
}