@@ -49,6 +49,21 @@ func (issue *Issue) ProjectColumnID(ctx context.Context) (int64, error) {
49
49
return ip .ProjectColumnID , nil
50
50
}
51
51
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
+
52
67
// LoadIssuesFromColumn load issues assigned to this column
53
68
func LoadIssuesFromColumn (ctx context.Context , b * project_model.Column , opts * IssuesOptions ) (IssueList , error ) {
54
69
issueList , err := Issues (ctx , opts .Copy (func (o * IssuesOptions ) {
@@ -61,11 +76,11 @@ func LoadIssuesFromColumn(ctx context.Context, b *project_model.Column, opts *Is
61
76
}
62
77
63
78
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
+ }))
69
84
if err != nil {
70
85
return nil , err
71
86
}
@@ -79,19 +94,6 @@ func LoadIssuesFromColumn(ctx context.Context, b *project_model.Column, opts *Is
79
94
return issueList , nil
80
95
}
81
96
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
-
95
97
// IssueAssignOrRemoveProject changes the project associated with an issue
96
98
// If newProjectID is 0, the issue is removed from the project
97
99
func 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
112
114
return util .NewPermissionDeniedErrorf ("issue %d can't be accessed by project %d" , issue .ID , newProject .ID )
113
115
}
114
116
if newColumnID == 0 {
115
- newDefaultColumn , err := newProject .GetDefaultColumn (ctx )
117
+ newDefaultColumn , err := newProject .MustDefaultColumn (ctx )
116
118
if err != nil {
117
119
return err
118
120
}
0 commit comments