Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: migrate find issues to v1 store (#4403)

Danny Xu23327bcf2c69
diff --git a/backend/legacyapi/issue.go b/backend/legacyapi/issue.go
index 498794473c..28a7ce38c9 100644
--- a/backend/legacyapi/issue.go
+++ b/backend/legacyapi/issue.go
@@ -96,11 +96,7 @@ type IssueResponse struct {
// IssueCreate is the API message for creating an issue.
type IssueCreate struct {
- // Related fields
- ProjectID int `jsonapi:"attr,projectId"`
- PipelineID int
-
- // Domain specific fields
+ ProjectID int `jsonapi:"attr,projectId"`
Name string `jsonapi:"attr,name"`
Type IssueType `jsonapi:"attr,type"`
Description string `jsonapi:"attr,description"`
@@ -112,7 +108,6 @@ type IssueCreate struct {
// This consolidates the pipeline generation to backend because both frontend and VCS pipeline could create issues and
// we want the complexity resides in the backend.
CreateContext string `jsonapi:"attr,createContext"`
-
// ValidateOnly validates the request and previews the review, but does not actually post it.
ValidateOnly bool `jsonapi:"attr,validateOnly"`
}
@@ -207,31 +202,6 @@ type RollbackContext struct {
TaskIDList []int `json:"taskIdList"`
}
-// IssueFind is the API message for finding issues.
-type IssueFind struct {
- ID *int
-
- // Related fields
- ProjectID *int
-
- // Domain specific fields
- PipelineID *int
- // Find issue where principalID is either creator, assignee or subscriber
- PrincipalID *int
- // To support pagination, we add into creator, assignee and subscriber.
- // Only principleID or one of the following three fields can be set.
- CreatorID *int
- AssigneeID *int
- AssigneeNeedAttention *bool
- SubscriberID *int
-
- StatusList []IssueStatus
- // If specified, only find issues whose ID is smaller that SinceID.
- SinceID *int
- // If specified, then it will only fetch "Limit" most recently updated issues
- Limit *int
-}
-
// IssuePatch is the API message for patching an issue.
type IssuePatch struct {
Name *string `jsonapi:"attr,name"`
diff --git a/backend/server/issue.go b/backend/server/issue.go
index 2b5226bf32..206a443d3c 100644
--- a/backend/server/issue.go
+++ b/backend/server/issue.go
@@ -49,7 +49,7 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {
g.GET("/issue", func(c echo.Context) error {
ctx := c.Request().Context()
- issueFind := &api.IssueFind{}
+ issueFind := &store.FindIssueMessage{}
pageToken := c.QueryParams().Get("token")
// We use descending order by default for issues.
@@ -65,7 +65,7 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("project query parameter is not a number: %s", projectIDStr)).SetInternal(err)
}
- issueFind.ProjectID = &projectID
+ issueFind.ProjectUID = &projectID
}
if issueStatusListStr := c.QueryParam("status"); issueStatusListStr != "" {
statusList := []api.IssueStatus{}
diff --git a/backend/store/cache.go b/backend/store/cache.go
index f290db9fbd..96ff5f7534 100644
--- a/backend/store/cache.go
+++ b/backend/store/cache.go
@@ -15,8 +15,6 @@ type cacheNamespace string
const (
// pipelineCacheNamespace is the cache type of pipelines.
pipelineCacheNamespace cacheNamespace = "pl"
- // issueCacheNamespace is the cache type of issues.
- issueCacheNamespace cacheNamespace = "is"
)
// CacheService implements a cache.
diff --git a/backend/store/issue.go b/backend/store/issue.go
index 0c6740e764..61b8e5436c 100644
--- a/backend/store/issue.go
+++ b/backend/store/issue.go
@@ -15,96 +15,43 @@ import (
api "github.com/bytebase/bytebase/backend/legacyapi"
)
-// issueRaw is the store model for an Issue.
-// Fields have exactly the same meanings as Issue.
-type issueRaw struct {
- ID int
-
- // Standard fields
- CreatorID int
- CreatedTs int64
- UpdaterID int
- UpdatedTs int64
-
- // Related fields
- ProjectID int
- PipelineID int
-
- // Domain specific fields
- Name string
- Status api.IssueStatus
- Type api.IssueType
- Description string
- AssigneeID int
- AssigneeNeedAttention bool
- Payload string
-}
-
-// toIssue creates an instance of Issue based on the issueRaw.
-// This is intended to be called when we need to compose an Issue relationship.
-func (raw *issueRaw) toIssue() *api.Issue {
- return &api.Issue{
- ID: raw.ID,
-
- // Standard fields
- CreatorID: raw.CreatorID,
- CreatedTs: raw.CreatedTs,
- UpdaterID: raw.UpdaterID,
- UpdatedTs: raw.UpdatedTs,
-
- // Related fields
- ProjectID: raw.ProjectID,
- PipelineID: raw.PipelineID,
-
- // Domain specific fields
- Name: raw.Name,
- Status: raw.Status,
- Type: raw.Type,
- Description: raw.Description,
- AssigneeID: raw.AssigneeID,
- AssigneeNeedAttention: raw.AssigneeNeedAttention,
- Payload: raw.Payload,
- }
-}
-
// GetIssueByID gets an instance of Issue.
func (s *Store) GetIssueByID(ctx context.Context, id int) (*api.Issue, error) {
- find := &api.IssueFind{ID: &id}
- issueRaw, err := s.getIssueRaw(ctx, find)
+ issue, err := s.GetIssueV2(ctx, &FindIssueMessage{UID: &id})
if err != nil {
return nil, errors.Wrapf(err, "failed to get Issue with ID %d", id)
}
- if issueRaw == nil {
+ if issue == nil {
return nil, nil
}
- issue, err := s.composeIssue(ctx, issueRaw)
+ composedIssue, err := s.composeIssue(ctx, issue)
if err != nil {
- return nil, errors.Wrapf(err, "failed to compose Issue with issueRaw[%+v]", issueRaw)
+ return nil, errors.Wrapf(err, "failed to compose issue %d", id)
}
- return issue, nil
+ return composedIssue, nil
}
// FindIssueStripped finds a list of issues in stripped format.
// We do not load the pipeline in order to reduce the size of the response payload and the complexity of composing the issue list.
-func (s *Store) FindIssueStripped(ctx context.Context, find *api.IssueFind) ([]*api.Issue, error) {
- issueRawList, err := s.findIssueRaw(ctx, find)
+func (s *Store) FindIssueStripped(ctx context.Context, find *FindIssueMessage) ([]*api.Issue, error) {
+ issues, err := s.ListIssueV2(ctx, find)
if err != nil {
return nil, errors.Wrapf(err, "failed to find Issue list with IssueFind[%+v]", find)
}
- var issueList []*api.Issue
- for _, raw := range issueRawList {
- issue, err := s.composeIssueStripped(ctx, raw)
+ var composedIssues []*api.Issue
+ for _, issue := range issues {
+ issue, err := s.composeIssueStripped(ctx, issue)
if err != nil {
- return nil, errors.Wrapf(err, "failed to compose Issue with issueRaw[%+v]", raw)
+ return nil, errors.Wrapf(err, "failed to compose issue %d", issue.ID)
}
// If no specified project, filter out issues belonging to archived project
if issue == nil || issue.Project == nil || issue.Project.RowStatus == api.Archived {
continue
}
- issueList = append(issueList, issue)
+ composedIssues = append(composedIssues, issue)
}
- return issueList, nil
+ return composedIssues, nil
}
// CreateIssueValidateOnly creates an issue for validation purpose
@@ -281,106 +228,125 @@ func (s *Store) composeIssueValidateOnly(ctx context.Context, issue *api.Issue)
}
// Note: MUST keep in sync with composeIssueValidateOnly.
-func (s *Store) composeIssue(ctx context.Context, raw *issueRaw) (*api.Issue, error) {
- issue := raw.toIssue()
-
- creator, err := s.GetPrincipalByID(ctx, issue.CreatorID)
+func (s *Store) composeIssue(ctx context.Context, issue *IssueMessage) (*api.Issue, error) {
+ composedIssue := &api.Issue{
+ ID: issue.UID,
+ CreatorID: issue.Creator.ID,
+ CreatedTs: issue.CreatedTime.Unix(),
+ UpdaterID: issue.Updater.ID,
+ UpdatedTs: issue.UpdatedTime.Unix(),
+ ProjectID: issue.Project.UID,
+ PipelineID: issue.PipelineUID,
+ Name: issue.Title,
+ Status: issue.Status,
+ Type: issue.Type,
+ Description: issue.Description,
+ AssigneeID: issue.Assignee.ID,
+ AssigneeNeedAttention: issue.NeedAttention,
+ Payload: issue.Payload,
+ }
+
+ creator, err := s.GetPrincipalByID(ctx, issue.Creator.ID)
if err != nil {
return nil, err
}
- issue.Creator = creator
-
- updater, err := s.GetPrincipalByID(ctx, issue.UpdaterID)
+ composedIssue.Creator = creator
+ updater, err := s.GetPrincipalByID(ctx, issue.Updater.ID)
if err != nil {
return nil, err
}
- issue.Updater = updater
-
- assignee, err := s.GetPrincipalByID(ctx, issue.AssigneeID)
+ composedIssue.Updater = updater
+ assignee, err := s.GetPrincipalByID(ctx, issue.Assignee.ID)
if err != nil {
return nil, err
}
- issue.Assignee = assignee
+ composedIssue.Assignee = assignee
- issueSubscriberFind := &api.IssueSubscriberFind{
- IssueID: &issue.ID,
- }
- issueSubscriberList, err := s.FindIssueSubscriber(ctx, issueSubscriberFind)
- if err != nil {
- return nil, err
- }
- for _, issueSub := range issueSubscriberList {
- issue.SubscriberList = append(issue.SubscriberList, issueSub.Subscriber)
+ for _, subscriber := range issue.Subscribers {
+ composedSubscriber, err := s.GetPrincipalByID(ctx, subscriber.ID)
+ if err != nil {
+ return nil, err
+ }
+ composedIssue.SubscriberList = append(composedIssue.SubscriberList, composedSubscriber)
}
- project, err := s.GetProjectByID(ctx, issue.ProjectID)
+ composedProject, err := s.GetProjectByID(ctx, issue.Project.UID)
if err != nil {
return nil, err
}
- issue.Project = project
+ composedIssue.Project = composedProject
- pipeline, err := s.GetPipelineByID(ctx, issue.PipelineID)
+ composedPipeline, err := s.GetPipelineByID(ctx, issue.PipelineUID)
if err != nil {
return nil, err
}
- issue.Pipeline = pipeline
+ composedIssue.Pipeline = composedPipeline
- return issue, nil
+ return composedIssue, nil
}
// composeIssueStripped is a stripped version of compose issue only used in listing issues
// for reducing the cost and payload of composing a full issue.
-func (s *Store) composeIssueStripped(ctx context.Context, raw *issueRaw) (*api.Issue, error) {
- issue := raw.toIssue()
-
- creator, err := s.GetPrincipalByID(ctx, issue.CreatorID)
+func (s *Store) composeIssueStripped(ctx context.Context, issue *IssueMessage) (*api.Issue, error) {
+ composedIssue := &api.Issue{
+ ID: issue.UID,
+ CreatorID: issue.Creator.ID,
+ CreatedTs: issue.CreatedTime.Unix(),
+ UpdaterID: issue.Updater.ID,
+ UpdatedTs: issue.UpdatedTime.Unix(),
+ ProjectID: issue.Project.UID,
+ PipelineID: issue.PipelineUID,
+ Name: issue.Title,
+ Status: issue.Status,
+ Type: issue.Type,
+ Description: issue.Description,
+ AssigneeID: issue.Assignee.ID,
+ AssigneeNeedAttention: issue.NeedAttention,
+ Payload: issue.Payload,
+ }
+
+ creator, err := s.GetPrincipalByID(ctx, issue.Creator.ID)
if err != nil {
return nil, err
}
- issue.Creator = creator
-
- updater, err := s.GetPrincipalByID(ctx, issue.UpdaterID)
+ composedIssue.Creator = creator
+ updater, err := s.GetPrincipalByID(ctx, issue.Updater.ID)
if err != nil {
return nil, err
}
- issue.Updater = updater
-
- assignee, err := s.GetPrincipalByID(ctx, issue.AssigneeID)
+ composedIssue.Updater = updater
+ assignee, err := s.GetPrincipalByID(ctx, issue.Assignee.ID)
if err != nil {
return nil, err
}
- issue.Assignee = assignee
+ composedIssue.Assignee = assignee
- // TODO(d): add subscriber caching.
- issueSubscriberFind := &api.IssueSubscriberFind{
- IssueID: &issue.ID,
- }
- issueSubscriberList, err := s.FindIssueSubscriber(ctx, issueSubscriberFind)
- if err != nil {
- return nil, err
- }
- for _, issueSub := range issueSubscriberList {
- issue.SubscriberList = append(issue.SubscriberList, issueSub.Subscriber)
+ for _, subscriber := range issue.Subscribers {
+ composedSubscriber, err := s.GetPrincipalByID(ctx, subscriber.ID)
+ if err != nil {
+ return nil, err
+ }
+ composedIssue.SubscriberList = append(composedIssue.SubscriberList, composedSubscriber)
}
- project, err := s.GetProjectByID(ctx, issue.ProjectID)
+ composedProject, err := s.GetProjectByID(ctx, issue.Project.UID)
if err != nil {
return nil, err
}
- issue.Project = project
+ composedIssue.Project = composedProject
// Creating a stripped pipeline.
- find := &api.PipelineFind{ID: &issue.PipelineID}
+ find := &api.PipelineFind{ID: &issue.PipelineUID}
pipelineRaw, err := s.getPipelineRaw(ctx, find)
if err != nil {
- return nil, errors.Wrapf(err, "failed to get Pipeline with ID %d", issue.PipelineID)
+ return nil, errors.Wrapf(err, "failed to get Pipeline with ID %d", issue.PipelineUID)
}
if pipelineRaw == nil {
return nil, nil
}
pipeline := pipelineRaw.toPipeline()
- stageRawList, err := s.findStageRaw(ctx, &api.StageFind{PipelineID: &issue.PipelineID})
+ stageRawList, err := s.findStageRaw(ctx, &api.StageFind{PipelineID: &issue.PipelineUID})
if err != nil {
return nil, errors.Wrapf(err, "failed to find Stage list with StageFind[%+v]", find)
}
@@ -406,166 +372,9 @@ func (s *Store) composeIssueStripped(ctx context.Context, raw *issueRaw) (*api.I
stageList = append(stageList, stage)
}
pipeline.StageList = stageList
+ composedIssue.Pipeline = pipeline
- issue.Pipeline = pipeline
-
- return issue, nil
-}
-
-// findIssueRaw retrieves a list of issues based on find.
-func (s *Store) findIssueRaw(ctx context.Context, find *api.IssueFind) ([]*issueRaw, error) {
- tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
- if err != nil {
- return nil, FormatError(err)
- }
- defer tx.Rollback()
-
- list, err := s.findIssueImpl(ctx, tx, find)
- if err != nil {
- return nil, err
- }
-
- if err == nil {
- for _, issue := range list {
- if err := s.cache.UpsertCache(issueCacheNamespace, issue.ID, issue); err != nil {
- return nil, err
- }
- }
- }
-
- return list, nil
-}
-
-// getIssueRaw retrieves a single issue based on find.
-// Returns ECONFLICT if finding more than 1 matching records.
-func (s *Store) getIssueRaw(ctx context.Context, find *api.IssueFind) (*issueRaw, error) {
- tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
- if err != nil {
- return nil, FormatError(err)
- }
- defer tx.Rollback()
-
- list, err := s.findIssueImpl(ctx, tx, find)
- if err != nil {
- return nil, err
- }
-
- if len(list) == 0 {
- return nil, nil
- } else if len(list) > 1 {
- return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d issues with filter %+v, expect 1", len(list), find)}
- }
- if err := s.cache.UpsertCache(issueCacheNamespace, list[0].ID, list[0]); err != nil {
- return nil, err
- }
- return list[0], nil
-}
-
-func (*Store) findIssueImpl(ctx context.Context, tx *Tx, find *api.IssueFind) ([]*issueRaw, error) {
- // Build WHERE clause.
- where, args := []string{"TRUE"}, []interface{}{}
- if v := find.ID; v != nil {
- where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, *v)
- }
- if v := find.PipelineID; v != nil {
- where, args = append(where, fmt.Sprintf("pipeline_id = $%d", len(args)+1)), append(args, *v)
- }
- if v := find.ProjectID; v != nil {
- where, args = append(where, fmt.Sprintf("project_id = $%d", len(args)+1)), append(args, *v)
- }
- if v := find.PrincipalID; v != nil {
- if find.CreatorID != nil || find.AssigneeID != nil || find.SubscriberID != nil {
- return nil, &common.Error{Code: common.Invalid, Err: errors.New("principal_id cannot be used with creator_id, assignee_id, or subscriber_id")}
- }
- where = append(where, fmt.Sprintf("(creator_id = $%d OR assignee_id = $%d OR EXISTS (SELECT 1 FROM issue_subscriber WHERE issue_id = issue.id AND subscriber_id = $%d))", len(args)+1, len(args)+2, len(args)+3))
- args = append(args, *v)
- args = append(args, *v)
- args = append(args, *v)
- }
- if v := find.CreatorID; v != nil {
- where, args = append(where, fmt.Sprintf("creator_id = $%d", len(args)+1)), append(args, *v)
- }
- if v := find.AssigneeID; v != nil {
- where, args = append(where, fmt.Sprintf("assignee_id = $%d", len(args)+1)), append(args, *v)
- }
- if v := find.AssigneeNeedAttention; v != nil {
- where, args = append(where, fmt.Sprintf("assignee_need_attention = $%d", len(args)+1)), append(args, *v)
- }
- if v := find.SubscriberID; v != nil {
- where, args = append(where, fmt.Sprintf("EXISTS (SELECT 1 FROM issue_subscriber WHERE issue_id = issue.id AND subscriber_id = $%d)", len(args)+1)), append(args, *v)
- }
- if v := find.SinceID; v != nil {
- where, args = append(where, fmt.Sprintf("id <= $%d", len(args)+1)), append(args, *v)
- }
-
- if len(find.StatusList) != 0 {
- list := []string{}
- for _, status := range find.StatusList {
- list = append(list, fmt.Sprintf("$%d", len(args)+1))
- args = append(args, status)
- }
- where = append(where, fmt.Sprintf("status IN (%s)", strings.Join(list, ",")))
- }
-
- query := `
- SELECT
- id,
- creator_id,
- created_ts,
- updater_id,
- updated_ts,
- project_id,
- pipeline_id,
- name,
- status,
- type,
- description,
- assignee_id,
- assignee_need_attention,
- payload
- FROM issue
- WHERE ` + strings.Join(where, " AND ")
- query += " ORDER BY id DESC"
- if v := find.Limit; v != nil {
- query += fmt.Sprintf(" LIMIT %d", *v)
- }
-
- rows, err := tx.QueryContext(ctx, query, args...)
- if err != nil {
- return nil, FormatError(err)
- }
- defer rows.Close()
-
- // Iterate over result set and deserialize rows into issuerRawList.
- var issuerRawList []*issueRaw
- for rows.Next() {
- var issueRaw issueRaw
- if err := rows.Scan(
- &issueRaw.ID,
- &issueRaw.CreatorID,
- &issueRaw.CreatedTs,
- &issueRaw.UpdaterID,
- &issueRaw.UpdatedTs,
- &issueRaw.ProjectID,
- &issueRaw.PipelineID,
- &issueRaw.Name,
- &issueRaw.Status,
- &issueRaw.Type,
- &issueRaw.Description,
- &issueRaw.AssigneeID,
- &issueRaw.AssigneeNeedAttention,
- &issueRaw.Payload,
- ); err != nil {
- return nil, FormatError(err)
- }
-
- issuerRawList = append(issuerRawList, &issueRaw)
- }
- if err := rows.Err(); err != nil {
- return nil, FormatError(err)
- }
-
- return issuerRawList, nil
+ return composedIssue, nil
}
// IssueMessage is the mssage for issues.
@@ -796,7 +605,6 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
if v := find.SinceID; v != nil {
where, args = append(where, fmt.Sprintf("issue.id <= $%d", len(args)+1)), append(args, *v)
}
-
if len(find.StatusList) != 0 {
var list []string
for _, status := range find.StatusList {
@@ -805,6 +613,11 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
}
where = append(where, fmt.Sprintf("issue.status IN (%s)", strings.Join(list, ", ")))
}
+ limitClause := ""
+ if v := find.Limit; v != nil {
+ limitClause = fmt.Sprintf(" LIMIT %d", *v)
+ }
+
var issues []*IssueMessage
tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
if err != nil {
@@ -834,7 +647,9 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
FROM issue
LEFT JOIN issue_subscriber ON issue.id = issue_subscriber.issue_id
WHERE %s
- GROUP BY issue.id`, strings.Join(where, " AND ")),
+ GROUP BY issue.id
+ ORDER BY issue.id DESC
+ %s`, strings.Join(where, " AND "), limitClause),
args...,
)
if err != nil {
diff --git a/backend/tests/external_approval_test.go b/backend/tests/external_approval_test.go
index 52d9e3cdf7..8209f13c1c 100644
--- a/backend/tests/external_approval_test.go
+++ b/backend/tests/external_approval_test.go
@@ -32,7 +32,7 @@ func TestExternalApprovalFeishu_AllUserCanBeFound(t *testing.T) {
a.NoError(err)
// close existing issues
- issues, err := ctl.getIssues(api.IssueFind{})
+ issues, err := ctl.getIssues(nil /* projectID */)
a.NoError(err)
for _, issue := range issues {
patchedIssue, err := ctl.patchIssueStatus(api.IssueStatusPatch{
@@ -186,7 +186,7 @@ func TestExternalApprovalFeishu_AssigneeCanBeFound(t *testing.T) {
a.NoError(err)
// close existing issues
- issues, err := ctl.getIssues(api.IssueFind{})
+ issues, err := ctl.getIssues(nil /* projectID */)
a.NoError(err)
for _, issue := range issues {
patchedIssue, err := ctl.patchIssueStatus(api.IssueStatusPatch{
diff --git a/backend/tests/issue.go b/backend/tests/issue.go
index 36e5d725a7..146abb97c1 100644
--- a/backend/tests/issue.go
+++ b/backend/tests/issue.go
@@ -47,12 +47,12 @@ func (ctl *controller) getIssue(id int) (*api.Issue, error) {
}
// getIssue gets the issue with given ID.
-func (ctl *controller) getIssues(issueFind api.IssueFind) ([]*api.Issue, error) {
+func (ctl *controller) getIssues(projectID *int, statusList ...api.IssueStatus) ([]*api.Issue, error) {
var ret []*api.Issue
// call getOnePageIssuesWithToken until no more issues.
token := ""
for {
- issues, nextToken, err := ctl.getOnePageIssuesWithToken(issueFind, token)
+ issues, nextToken, err := ctl.getOnePageIssuesWithToken(projectID, statusList, token)
if err != nil {
return nil, err
}
@@ -65,14 +65,14 @@ func (ctl *controller) getIssues(issueFind api.IssueFind) ([]*api.Issue, error)
return ret, nil
}
-func (ctl *controller) getOnePageIssuesWithToken(issueFind api.IssueFind, token string) ([]*api.Issue, string, error) {
+func (ctl *controller) getOnePageIssuesWithToken(projectID *int, statusList []api.IssueStatus, token string) ([]*api.Issue, string, error) {
params := make(map[string]string)
- if issueFind.ProjectID != nil {
- params["project"] = fmt.Sprintf("%d", *issueFind.ProjectID)
+ if projectID != nil {
+ params["project"] = fmt.Sprintf("%d", *projectID)
}
- if len(issueFind.StatusList) > 0 {
+ if len(statusList) > 0 {
var sl []string
- for _, status := range issueFind.StatusList {
+ for _, status := range statusList {
sl = append(sl, string(status))
}
params["status"] = strings.Join(sl, ",")
diff --git a/backend/tests/schema_update_test.go b/backend/tests/schema_update_test.go
index 9b5ec94a3a..4dc6081a9a 100644
--- a/backend/tests/schema_update_test.go
+++ b/backend/tests/schema_update_test.go
@@ -465,13 +465,7 @@ func TestVCS(t *testing.T) {
a.NoError(err)
// Get schema update issue.
- openStatus := []api.IssueStatus{api.IssueOpen}
- issues, err := ctl.getIssues(
- api.IssueFind{
- ProjectID: &project.ID,
- StatusList: openStatus,
- },
- )
+ issues, err := ctl.getIssues(&project.ID, api.IssueOpen)
a.NoError(err)
a.Len(issues, 1)
issue := issues[0]
@@ -511,13 +505,7 @@ func TestVCS(t *testing.T) {
a.NoError(err)
// Get data update issue.
- openStatus = []api.IssueStatus{api.IssueOpen}
- issues, err = ctl.getIssues(
- api.IssueFind{
- ProjectID: &project.ID,
- StatusList: openStatus,
- },
- )
+ issues, err = ctl.getIssues(&project.ID, api.IssueOpen)
a.NoError(err)
a.Len(issues, 1)
issue = issues[0]
@@ -538,13 +526,7 @@ func TestVCS(t *testing.T) {
a.NoError(err)
// Get data update issue.
- openStatus = []api.IssueStatus{api.IssueOpen}
- issues, err = ctl.getIssues(
- api.IssueFind{
- ProjectID: &project.ID,
- StatusList: openStatus,
- },
- )
+ issues, err = ctl.getIssues(&project.ID, api.IssueOpen)
a.NoError(err)
a.Len(issues, 1)
issue = issues[0]
@@ -855,13 +837,7 @@ func TestVCS_SDL(t *testing.T) {
a.NoError(err)
// Get schema update issue
- openStatus := []api.IssueStatus{api.IssueOpen}
- issues, err := ctl.getIssues(
- api.IssueFind{
- ProjectID: &project.ID,
- StatusList: openStatus,
- },
- )
+ issues, err := ctl.getIssues(&project.ID, api.IssueOpen)
a.NoError(err)
a.Len(issues, 1)
issue := issues[0]
@@ -896,13 +872,7 @@ func TestVCS_SDL(t *testing.T) {
a.NoError(err)
// Get data update issue
- openStatus = []api.IssueStatus{api.IssueOpen}
- issues, err = ctl.getIssues(
- api.IssueFind{
- ProjectID: &project.ID,
- StatusList: openStatus,
- },
- )
+ issues, err = ctl.getIssues(&project.ID, api.IssueOpen)
a.NoError(err)
a.Len(issues, 1)
issue = issues[0]
@@ -1331,13 +1301,7 @@ func TestWildcardInVCSFilePathTemplate(t *testing.T) {
a.NoError(err)
// Check for newly generated issues.
- openStatus := []api.IssueStatus{api.IssueOpen}
- issues, err := ctl.getIssues(
- api.IssueFind{
- ProjectID: &project.ID,
- StatusList: openStatus,
- },
- )
+ issues, err := ctl.getIssues(&project.ID, api.IssueOpen)
a.NoError(err)
if test.expect[idx] {
a.Len(issues, 1)
diff --git a/backend/tests/tenant_test.go b/backend/tests/tenant_test.go
index ed349605ab..b2742d31a1 100644
--- a/backend/tests/tenant_test.go
+++ b/backend/tests/tenant_test.go
@@ -445,13 +445,7 @@ func TestTenantVCS(t *testing.T) {
a.NoError(err)
// Get schema update issue.
- openStatus := []api.IssueStatus{api.IssueOpen}
- issues, err := ctl.getIssues(
- api.IssueFind{
- ProjectID: &project.ID,
- StatusList: openStatus,
- },
- )
+ issues, err := ctl.getIssues(&project.ID, api.IssueOpen)
a.NoError(err)
a.Len(issues, 1)
issue := issues[0]
@@ -897,13 +891,7 @@ func TestTenantVCSDatabaseNameTemplate(t *testing.T) {
a.NoError(err)
// Get schema update issue.
- openStatus := []api.IssueStatus{api.IssueOpen}
- issues, err := ctl.getIssues(
- api.IssueFind{
- ProjectID: &project.ID,
- StatusList: openStatus,
- },
- )
+ issues, err := ctl.getIssues(&project.ID, api.IssueOpen)
a.NoError(err)
a.Len(issues, 1)
issue := issues[0]
@@ -1213,13 +1201,7 @@ func TestTenantVCSDatabaseNameTemplate_Empty(t *testing.T) {
a.NoError(err)
// Get schema update issues.
- openStatus := []api.IssueStatus{api.IssueOpen}
- issues, err := ctl.getIssues(
- api.IssueFind{
- ProjectID: &project.ID,
- StatusList: openStatus,
- },
- )
+ issues, err := ctl.getIssues(&project.ID, api.IssueOpen)
a.NoError(err)
a.Len(issues, 1)
issue := issues[0]
@@ -1497,13 +1479,7 @@ func TestTenantVCS_YAML(t *testing.T) {
require.NoError(t, err)
// Get schema update issues.
- openStatus := []api.IssueStatus{api.IssueOpen}
- issues, err := ctl.getIssues(
- api.IssueFind{
- ProjectID: &project.ID,
- StatusList: openStatus,
- },
- )
+ issues, err := ctl.getIssues(&project.ID, api.IssueOpen)
require.NoError(t, err)
require.Len(t, issues, 1)
status, err := ctl.waitIssuePipeline(issues[0].ID)
@@ -1536,13 +1512,7 @@ statement: |
require.NoError(t, err)
// Get data update issues.
- openStatus = []api.IssueStatus{api.IssueOpen}
- issues, err = ctl.getIssues(
- api.IssueFind{
- ProjectID: &project.ID,
- StatusList: openStatus,
- },
- )
+ issues, err = ctl.getIssues(&project.ID, api.IssueOpen)
require.NoError(t, err)
status, err = ctl.waitIssuePipeline(issues[0].ID)
require.NoError(t, err)