API Cleanup

This commit is contained in:
2017-11-18 11:37:29 +01:00
parent bd293de4be
commit c5cb497722
7 changed files with 37 additions and 31 deletions

View File

@ -0,0 +1,31 @@
package companies
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxEntries = 12
// Get renders the companies page.
func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
companies := arn.FilterCompanies(func(company *arn.Company) bool {
return !company.IsDraft
})
if err != nil {
return ctx.Error(http.StatusInternalServerError, "Error fetching companies", err)
}
if len(companies) > maxEntries {
companies = companies[:maxEntries]
}
return ctx.HTML(components.Companies(companies, user))
}

View File