Refactor issue indexer (#5363)
This commit is contained in:
parent
094263db4d
commit
830ae61456
22 changed files with 1046 additions and 117 deletions
|
@ -183,12 +183,21 @@ func (issue *Issue) LoadPullRequest() error {
|
|||
}
|
||||
|
||||
func (issue *Issue) loadComments(e Engine) (err error) {
|
||||
return issue.loadCommentsByType(e, CommentTypeUnknown)
|
||||
}
|
||||
|
||||
// LoadDiscussComments loads discuss comments
|
||||
func (issue *Issue) LoadDiscussComments() error {
|
||||
return issue.loadCommentsByType(x, CommentTypeComment)
|
||||
}
|
||||
|
||||
func (issue *Issue) loadCommentsByType(e Engine, tp CommentType) (err error) {
|
||||
if issue.Comments != nil {
|
||||
return nil
|
||||
}
|
||||
issue.Comments, err = findComments(e, FindCommentsOptions{
|
||||
IssueID: issue.ID,
|
||||
Type: CommentTypeUnknown,
|
||||
Type: tp,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
@ -681,7 +690,6 @@ func updateIssueCols(e Engine, issue *Issue, cols ...string) error {
|
|||
if _, err := e.ID(issue.ID).Cols(cols...).Update(issue); err != nil {
|
||||
return err
|
||||
}
|
||||
UpdateIssueIndexerCols(issue.ID, cols...)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -1217,6 +1225,12 @@ func getIssuesByIDs(e Engine, issueIDs []int64) ([]*Issue, error) {
|
|||
return issues, e.In("id", issueIDs).Find(&issues)
|
||||
}
|
||||
|
||||
func getIssueIDsByRepoID(e Engine, repoID int64) ([]int64, error) {
|
||||
var ids = make([]int64, 0, 10)
|
||||
err := e.Table("issue").Where("repo_id = ?", repoID).Find(&ids)
|
||||
return ids, err
|
||||
}
|
||||
|
||||
// GetIssuesByIDs return issues with the given IDs.
|
||||
func GetIssuesByIDs(issueIDs []int64) ([]*Issue, error) {
|
||||
return getIssuesByIDs(x, issueIDs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue