Fix getting labels, lists or teams if none are available
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
kolaente 2021-02-02 23:10:50 +01:00
parent 1635beda56
commit cfb15a27f0
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 25 additions and 0 deletions

View File

@ -208,6 +208,10 @@ func getLabelsByTaskIDs(s *xorm.Session, opts *LabelByTaskIDsOptions) (ls []*lab
return nil, 0, 0, err
}
if len(labels) == 0 {
return nil, 0, 0, nil
}
// Get all created by users
var userids []int64
for _, l := range labels {

View File

@ -389,6 +389,10 @@ func getRawListsForUser(s *xorm.Session, opts *listOptions) (lists []*List, resu
// addListDetails adds owner user objects and list tasks to all lists in the slice
func addListDetails(s *xorm.Session, lists []*List) (err error) {
if len(lists) == 0 {
return
}
var ownerIDs []int64
for _, l := range lists {
ownerIDs = append(ownerIDs, l.OwnerID)
@ -412,6 +416,10 @@ func addListDetails(s *xorm.Session, lists []*List) (err error) {
fileIDs = append(fileIDs, l.BackgroundFileID)
}
if len(fileIDs) == 0 {
return
}
// Unsplash background file info
us := []*UnsplashPhoto{}
err = s.In("file_id", fileIDs).Find(&us)

View File

@ -531,6 +531,14 @@ func (n *Namespace) Delete(s *xorm.Session, a web.Auth) (err error) {
if err != nil {
return
}
if len(lists) == 0 {
return events.Dispatch(&NamespaceDeletedEvent{
Namespace: n,
Doer: a,
})
}
var listIDs []int64
// We need to do that for here because we need the list ids to delete two times:
// 1) to delete the lists itself

View File

@ -120,6 +120,11 @@ func GetTeamByID(s *xorm.Session, id int64) (team *Team, err error) {
}
func addMoreInfoToTeams(s *xorm.Session, teams []*Team) (err error) {
if len(teams) == 0 {
return nil
}
// Put the teams in a map to make assigning more info to it more efficient
teamMap := make(map[int64]*Team, len(teams))
var teamIDs []int64