Editors can now add anime from scratch

This commit is contained in:
2019-10-16 14:44:53 +09:00
parent 5ec435cf99
commit 75c03c7bdc
9 changed files with 180 additions and 62 deletions

View File

@ -2,6 +2,7 @@ package arn
import (
"errors"
"sort"
"sync"
"github.com/aerogo/nano"
@ -81,6 +82,17 @@ func (characters *AnimeCharacters) Self() Loggable {
return characters
}
// Sort sorts the characters by role.
func (characters *AnimeCharacters) Sort() {
characters.Lock()
defer characters.Unlock()
sort.Slice(characters.Items, func(i, j int) bool {
// A little trick because "main" < "supporting"
return characters.Items[i].Role < characters.Items[j].Role
})
}
// Contains tells you whether the given character ID exists.
func (characters *AnimeCharacters) Contains(characterID string) bool {
characters.Lock()