mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Batch updates for issues (#926)
This commit is contained in:
committed by
Kim "BKC" Carlbäcker
parent
021904e4e6
commit
09fe4a2ae9
@@ -1002,6 +1002,16 @@ func GetIssueByID(id int64) (*Issue, error) {
|
||||
return getIssueByID(x, id)
|
||||
}
|
||||
|
||||
func getIssuesByIDs(e Engine, issueIDs []int64) ([]*Issue, error) {
|
||||
issues := make([]*Issue, 0, 10)
|
||||
return issues, e.In("id", issueIDs).Find(&issues)
|
||||
}
|
||||
|
||||
// GetIssuesByIDs return issues with the given IDs.
|
||||
func GetIssuesByIDs(issueIDs []int64) ([]*Issue, error) {
|
||||
return getIssuesByIDs(x, issueIDs)
|
||||
}
|
||||
|
||||
// IssuesOptions represents options of an issue.
|
||||
type IssuesOptions struct {
|
||||
RepoID int64
|
||||
|
@@ -42,3 +42,19 @@ func TestIssueAPIURL(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/issues/1", issue.APIURL())
|
||||
}
|
||||
|
||||
func TestGetIssuesByIDs(t *testing.T) {
|
||||
assert.NoError(t, PrepareTestDatabase())
|
||||
testSuccess := func(expectedIssueIDs []int64, nonExistentIssueIDs []int64) {
|
||||
issues, err := GetIssuesByIDs(append(expectedIssueIDs, nonExistentIssueIDs...))
|
||||
assert.NoError(t, err)
|
||||
actualIssueIDs := make([]int64, len(issues))
|
||||
for i, issue := range issues {
|
||||
actualIssueIDs[i] = issue.ID
|
||||
}
|
||||
assert.Equal(t, expectedIssueIDs, actualIssueIDs)
|
||||
|
||||
}
|
||||
testSuccess([]int64{1, 2, 3}, []int64{})
|
||||
testSuccess([]int64{1, 2, 3}, []int64{NonexistentID})
|
||||
}
|
||||
|
Reference in New Issue
Block a user