|
|
@ -982,6 +982,31 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) { |
|
|
|
return opts.Issue.addCrossReferences(e, doer, false) |
|
|
|
return opts.Issue.addCrossReferences(e, doer, false) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// RecalculateIssueIndexForRepo create issue_index for repo if not exist and
|
|
|
|
|
|
|
|
// update it based on highest index of existing issues assigned to a repo
|
|
|
|
|
|
|
|
func RecalculateIssueIndexForRepo(repoID int64) error { |
|
|
|
|
|
|
|
sess := x.NewSession() |
|
|
|
|
|
|
|
defer sess.Close() |
|
|
|
|
|
|
|
if err := sess.Begin(); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err := upsertResourceIndex(sess, "issue_index", repoID); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var max int64 |
|
|
|
|
|
|
|
if _, err := sess.Select(" MAX(`index`)").Table("issue").Where("repo_id=?", repoID).Get(&max); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _, err := sess.Exec("UPDATE `issue_index` SET max_index=? WHERE group_id=?", max, repoID); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return sess.Commit() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NewIssue creates new issue with labels for repository.
|
|
|
|
// NewIssue creates new issue with labels for repository.
|
|
|
|
func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string) (err error) { |
|
|
|
func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string) (err error) { |
|
|
|
idx, err := GetNextResourceIndex("issue_index", repo.ID) |
|
|
|
idx, err := GetNextResourceIndex("issue_index", repo.ID) |
|
|
|