Add getting users of a bucket
This commit is contained in:
parent
f027b744ef
commit
de20a17455
|
@ -74,11 +74,12 @@ func (b *Bucket) ReadAll(auth web.Auth, search string, page int, perPage int) (r
|
|||
buckets := []*Bucket{
|
||||
{
|
||||
// This is the default bucket for all tasks which are not associated to a bucket.
|
||||
ID: 0,
|
||||
Title: "Not associated to a bucket",
|
||||
ListID: b.ListID,
|
||||
Created: timeutil.FromTime(time.Now()),
|
||||
Updated: timeutil.FromTime(time.Now()),
|
||||
ID: 0,
|
||||
Title: "Not associated to a bucket",
|
||||
ListID: b.ListID,
|
||||
Created: timeutil.FromTime(time.Now()),
|
||||
Updated: timeutil.FromTime(time.Now()),
|
||||
CreatedByID: auth.GetID(),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -94,8 +95,21 @@ func (b *Bucket) ReadAll(auth web.Auth, search string, page int, perPage int) (r
|
|||
|
||||
// Make a map from the bucket slice with their id as key so that we can use it to put the tasks in their buckets
|
||||
bucketMap := make(map[int64]*Bucket, len(buckets))
|
||||
userIDs := make([]int64, 0, len(buckets))
|
||||
for _, bb := range buckets {
|
||||
bucketMap[bb.ID] = bb
|
||||
userIDs = append(userIDs, bb.CreatedByID)
|
||||
}
|
||||
|
||||
// Get all users
|
||||
users := make(map[int64]*user.User)
|
||||
err = x.In("id", userIDs).Find(&users)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, bb := range buckets {
|
||||
bb.CreatedBy = users[bb.CreatedByID]
|
||||
}
|
||||
|
||||
// Get all tasks for this list
|
||||
|
|
Loading…
Reference in New Issue