small optimizations

This commit is contained in:
kolaente 2018-07-06 08:40:35 +02:00
parent 31eb916af2
commit 2d0d074f89
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -17,25 +17,21 @@ type List struct {
// GetListByID returns a list by its ID // GetListByID returns a list by its ID
func GetListByID(id int64) (list List, err error) { func GetListByID(id int64) (list List, err error) {
list.ID = id exists, err := x.ID(id).Get(&list) // tName ist hässlich, geht das nicht auch anders?
exists, err := x.Get(&list)
if err != nil { if err != nil {
return List{}, err return list, err
} }
if !exists { if !exists {
return List{}, ErrListDoesNotExist{ID: id} return list, ErrListDoesNotExist{ID: id}
} }
// Get the list owner // Get the list owner
user, _, err := GetUserByID(list.OwnerID) list.Owner, _, err = GetUserByID(list.OwnerID)
if err != nil { if err != nil {
return List{}, err return List{}, err
} }
list.Owner = user
list.Owner.Password = ""
items, err := GetItemsByListID(list.ID) items, err := GetItemsByListID(list.ID)
if err != nil { if err != nil {
return return