small optimizations
This commit is contained in:
parent
31eb916af2
commit
2d0d074f89
1 changed files with 4 additions and 8 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue