Sort character anime by date
This commit is contained in:
@ -2,6 +2,7 @@ package character
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
@ -19,5 +20,19 @@ func Get(ctx *aero.Context) string {
|
||||
return ctx.Error(http.StatusNotFound, "Character not found", err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.CharacterDetails(character, user))
|
||||
characterAnime := character.Anime()
|
||||
|
||||
sort.Slice(characterAnime, func(i, j int) bool {
|
||||
if characterAnime[i].StartDate == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
if characterAnime[j].StartDate == "" {
|
||||
return true
|
||||
}
|
||||
|
||||
return characterAnime[i].StartDate < characterAnime[j].StartDate
|
||||
})
|
||||
|
||||
return ctx.HTML(components.CharacterDetails(character, characterAnime, user))
|
||||
}
|
||||
|
Reference in New Issue
Block a user