@@ -49,6 +49,21 @@ func (issue *Issue) ProjectColumnID(ctx context.Context) (int64, error) {
4949	return  ip .ProjectColumnID , nil 
5050}
5151
52+ func  LoadProjectIssueColumnMap (ctx  context.Context , projectID , defaultColumnID  int64 ) (map [int64 ]int64 , error ) {
53+ 	issues  :=  make ([]project_model.ProjectIssue , 0 )
54+ 	if  err  :=  db .GetEngine (ctx ).Where ("project_id=?" , projectID ).Find (& issues ); err  !=  nil  {
55+ 		return  nil , err 
56+ 	}
57+ 	result  :=  make (map [int64 ]int64 , len (issues ))
58+ 	for  _ , issue  :=  range  issues  {
59+ 		if  issue .ProjectColumnID  ==  0  {
60+ 			issue .ProjectColumnID  =  defaultColumnID 
61+ 		}
62+ 		result [issue .IssueID ] =  issue .ProjectColumnID 
63+ 	}
64+ 	return  result , nil 
65+ }
66+ 
5267// LoadIssuesFromColumn load issues assigned to this column 
5368func  LoadIssuesFromColumn (ctx  context.Context , b  * project_model.Column , opts  * IssuesOptions ) (IssueList , error ) {
5469	issueList , err  :=  Issues (ctx , opts .Copy (func (o  * IssuesOptions ) {
@@ -61,11 +76,11 @@ func LoadIssuesFromColumn(ctx context.Context, b *project_model.Column, opts *Is
6176	}
6277
6378	if  b .Default  {
64- 		issues , err  :=  Issues (ctx , & IssuesOptions {
65- 			ProjectColumnID :  db .NoConditionID , 
66- 			ProjectID :        b .ProjectID , 
67- 			SortType :         "project-column-sorting" , 
68- 		})
79+ 		issues , err  :=  Issues (ctx , opts . Copy ( func ( o   * IssuesOptions )  {
80+ 			o . ProjectColumnID   =   db .NoConditionID 
81+ 			o . ProjectID   =   b .ProjectID 
82+ 			o . SortType   =   "project-column-sorting" 
83+ 		})) 
6984		if  err  !=  nil  {
7085			return  nil , err 
7186		}
@@ -79,19 +94,6 @@ func LoadIssuesFromColumn(ctx context.Context, b *project_model.Column, opts *Is
7994	return  issueList , nil 
8095}
8196
82- // LoadIssuesFromColumnList load issues assigned to the columns 
83- func  LoadIssuesFromColumnList (ctx  context.Context , bs  project_model.ColumnList , opts  * IssuesOptions ) (map [int64 ]IssueList , error ) {
84- 	issuesMap  :=  make (map [int64 ]IssueList , len (bs ))
85- 	for  i  :=  range  bs  {
86- 		il , err  :=  LoadIssuesFromColumn (ctx , bs [i ], opts )
87- 		if  err  !=  nil  {
88- 			return  nil , err 
89- 		}
90- 		issuesMap [bs [i ].ID ] =  il 
91- 	}
92- 	return  issuesMap , nil 
93- }
94- 
9597// IssueAssignOrRemoveProject changes the project associated with an issue 
9698// If newProjectID is 0, the issue is removed from the project 
9799func  IssueAssignOrRemoveProject (ctx  context.Context , issue  * Issue , doer  * user_model.User , newProjectID , newColumnID  int64 ) error  {
@@ -112,7 +114,7 @@ func IssueAssignOrRemoveProject(ctx context.Context, issue *Issue, doer *user_mo
112114				return  util .NewPermissionDeniedErrorf ("issue %d can't be accessed by project %d" , issue .ID , newProject .ID )
113115			}
114116			if  newColumnID  ==  0  {
115- 				newDefaultColumn , err  :=  newProject .GetDefaultColumn (ctx )
117+ 				newDefaultColumn , err  :=  newProject .MustDefaultColumn (ctx )
116118				if  err  !=  nil  {
117119					return  err 
118120				}
0 commit comments