mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 03:25:11 +01:00 
			
		
		
		
	Backport #33496 by @lunny Fix #33482 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
		
							parent
							
								
									200cb6140d
								
							
						
					
					
						commit
						2df7d0835a
					
				| @ -38,13 +38,15 @@ func (issue *Issue) projectID(ctx context.Context) int64 { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // ProjectColumnID return project column id if issue was assigned to one | // ProjectColumnID return project column id if issue was assigned to one | ||||||
| func (issue *Issue) ProjectColumnID(ctx context.Context) int64 { | func (issue *Issue) ProjectColumnID(ctx context.Context) (int64, error) { | ||||||
| 	var ip project_model.ProjectIssue | 	var ip project_model.ProjectIssue | ||||||
| 	has, err := db.GetEngine(ctx).Where("issue_id=?", issue.ID).Get(&ip) | 	has, err := db.GetEngine(ctx).Where("issue_id=?", issue.ID).Get(&ip) | ||||||
| 	if err != nil || !has { | 	if err != nil { | ||||||
| 		return 0 | 		return 0, err | ||||||
|  | 	} else if !has { | ||||||
|  | 		return 0, nil | ||||||
| 	} | 	} | ||||||
| 	return ip.ProjectColumnID | 	return ip.ProjectColumnID, nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // LoadIssuesFromColumn load issues assigned to this column | // LoadIssuesFromColumn load issues assigned to this column | ||||||
|  | |||||||
| @ -92,6 +92,11 @@ func getIssueIndexerData(ctx context.Context, issueID int64) (*internal.IndexerD | |||||||
| 		projectID = issue.Project.ID | 		projectID = issue.Project.ID | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	projectColumnID, err := issue.ProjectColumnID(ctx) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, false, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	return &internal.IndexerData{ | 	return &internal.IndexerData{ | ||||||
| 		ID:                 issue.ID, | 		ID:                 issue.ID, | ||||||
| 		RepoID:             issue.RepoID, | 		RepoID:             issue.RepoID, | ||||||
| @ -106,7 +111,7 @@ func getIssueIndexerData(ctx context.Context, issueID int64) (*internal.IndexerD | |||||||
| 		NoLabel:            len(labels) == 0, | 		NoLabel:            len(labels) == 0, | ||||||
| 		MilestoneID:        issue.MilestoneID, | 		MilestoneID:        issue.MilestoneID, | ||||||
| 		ProjectID:          projectID, | 		ProjectID:          projectID, | ||||||
| 		ProjectColumnID:    issue.ProjectColumnID(ctx), | 		ProjectColumnID:    projectColumnID, | ||||||
| 		PosterID:           issue.PosterID, | 		PosterID:           issue.PosterID, | ||||||
| 		AssigneeID:         issue.AssigneeID, | 		AssigneeID:         issue.AssigneeID, | ||||||
| 		MentionIDs:         mentionIDs, | 		MentionIDs:         mentionIDs, | ||||||
|  | |||||||
| @ -55,11 +55,12 @@ func MoveIssuesOnProjectColumn(ctx context.Context, doer *user_model.User, colum | |||||||
| 				continue | 				continue | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			_, err = db.Exec(ctx, "UPDATE `project_issue` SET project_board_id=?, sorting=? WHERE issue_id=?", column.ID, sorting, issueID) | 			projectColumnID, err := curIssue.ProjectColumnID(ctx) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
|  | 			if projectColumnID != column.ID { | ||||||
| 				// add timeline to issue | 				// add timeline to issue | ||||||
| 				if _, err := issues_model.CreateComment(ctx, &issues_model.CreateCommentOptions{ | 				if _, err := issues_model.CreateComment(ctx, &issues_model.CreateCommentOptions{ | ||||||
| 					Type:               issues_model.CommentTypeProjectColumn, | 					Type:               issues_model.CommentTypeProjectColumn, | ||||||
| @ -74,6 +75,12 @@ func MoveIssuesOnProjectColumn(ctx context.Context, doer *user_model.User, colum | |||||||
| 					return err | 					return err | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
|  | 
 | ||||||
|  | 			_, err = db.Exec(ctx, "UPDATE `project_issue` SET project_board_id=?, sorting=? WHERE issue_id=?", column.ID, sorting, issueID) | ||||||
|  | 			if err != nil { | ||||||
|  | 				return err | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
| 		return nil | 		return nil | ||||||
| 	}) | 	}) | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user