Kanban #393

Merged
konrad merged 14 commits from feature/kanban into master 2020-04-19 07:27:29 +00:00
1 changed files with 11 additions and 12 deletions
Showing only changes of commit eaa252b6ee - Show all commits

View File

@ -56,14 +56,6 @@ func getBucketByID(id int64) (b *Bucket, err error) {
return
}
// Create creates a new bucket
func (b *Bucket) Create(a web.Auth) (err error) {
b.CreatedByID = a.GetID()
_, err = x.Insert(b)
return
}
// ReadAll returns all buckets with their tasks for a certain list
func (b *Bucket) ReadAll(auth web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) {
@ -101,17 +93,24 @@ func (b *Bucket) ReadAll(auth web.Auth, search string, page int, perPage int) (r
return
}
// Put all tasks in their buckets
// All tasks which are not associated to any bucket will have bucket id 0 which is the nil value for int64
// Since we created a bucked with that id at the beginning, all tasks should be in there.
for _, task := range tasks {
bucketMap[task.BucketID].Tasks = append(bucketMap[task.BucketID].Tasks, task)
}
// Put all tasks in their buckets
// Put all tasks which are not explicitly associated to a bucket into a pseudo bucket
return buckets, len(buckets), int64(len(buckets)), nil
}
// Create creates a new bucket
func (b *Bucket) Create(a web.Auth) (err error) {
b.CreatedByID = a.GetID()
_, err = x.Insert(b)
return
}
// Update Updates an existing bucket
func (b *Bucket) Update() (err error) {
_, err = x.Where("id = ?", b.ID).Update(b)