Performance improvement for users page
This commit is contained in:
parent
16c76670e8
commit
bd293de4be
21
pages/company/company.go
Normal file
21
pages/company/company.go
Normal file
@ -0,0 +1,21 @@
|
||||
package company
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// Get company.
|
||||
func Get(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
company, err := arn.GetCompany(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusNotFound, "Company not found", err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.CompanyPage(company))
|
||||
}
|
2
pages/company/company.pixy
Normal file
2
pages/company/company.pixy
Normal file
@ -0,0 +1,2 @@
|
||||
component CompanyPage(company *arn.Company)
|
||||
h1= company.Name.English
|
@ -13,6 +13,7 @@ import (
|
||||
"github.com/animenotifier/notify.moe/pages/apiview"
|
||||
"github.com/animenotifier/notify.moe/pages/character"
|
||||
"github.com/animenotifier/notify.moe/pages/charge"
|
||||
"github.com/animenotifier/notify.moe/pages/company"
|
||||
"github.com/animenotifier/notify.moe/pages/compare"
|
||||
"github.com/animenotifier/notify.moe/pages/database"
|
||||
"github.com/animenotifier/notify.moe/pages/editanime"
|
||||
@ -92,6 +93,9 @@ func Configure(app *aero.Application) {
|
||||
// Characters
|
||||
l.Page("/character/:id", character.Get)
|
||||
|
||||
// Companies
|
||||
l.Page("/company/:id", company.Get)
|
||||
|
||||
// Settings
|
||||
l.Page("/settings", settings.Get(components.SettingsPersonal))
|
||||
l.Page("/settings/accounts", settings.Get(components.SettingsAccounts))
|
||||
|
@ -14,9 +14,15 @@ func Active(ctx *aero.Context) string {
|
||||
return user.IsActive() && user.HasAvatar()
|
||||
})
|
||||
|
||||
followCount := map[*arn.User]int{}
|
||||
|
||||
for _, user := range users {
|
||||
followCount[user] = user.FollowersCount()
|
||||
}
|
||||
|
||||
sort.Slice(users, func(i, j int) bool {
|
||||
followersA := users[i].FollowersCount()
|
||||
followersB := users[j].FollowersCount()
|
||||
followersA := followCount[users[i]]
|
||||
followersB := followCount[users[j]]
|
||||
|
||||
if followersA == followersB {
|
||||
return users[i].Nick < users[j].Nick
|
||||
|
Loading…
Reference in New Issue
Block a user