Skip to content

Commit 8f35848

Browse files
authored
add filter by status feature for tapd (#4276)
Signed-off-by: Patrick Zhao <[email protected]>
1 parent 361054f commit 8f35848

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

pkg/microservice/aslan/core/common/repository/models/workflow_v4.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,13 +1360,14 @@ type PingCodeJobSpec struct {
13601360
}
13611361

13621362
type TapdJobSpec struct {
1363-
TapdID string `bson:"tapd_id" json:"tapd_id" yaml:"tapd_id"`
1364-
Source config.ParamSourceType `bson:"source" json:"source" yaml:"source"`
1365-
Type string `bson:"type" json:"type" yaml:"type"`
1366-
ProjectID string `bson:"project_id" json:"project_id" yaml:"project_id"`
1367-
ProjectName string `bson:"project_name" json:"project_name" yaml:"project_name"`
1368-
Status config.TapdIterationStatus `bson:"status" json:"status" yaml:"status"`
1369-
Iterations []*TapdIteration `bson:"iterations" json:"iterations" yaml:"iterations"`
1363+
TapdID string `bson:"tapd_id" json:"tapd_id" yaml:"tapd_id"`
1364+
Source config.ParamSourceType `bson:"source" json:"source" yaml:"source"`
1365+
Type string `bson:"type" json:"type" yaml:"type"`
1366+
ProjectID string `bson:"project_id" json:"project_id" yaml:"project_id"`
1367+
ProjectName string `bson:"project_name" json:"project_name" yaml:"project_name"`
1368+
SourceStatus config.TapdIterationStatus `bson:"source_status" json:"source_status" yaml:"source_status"`
1369+
Status config.TapdIterationStatus `bson:"status" json:"status" yaml:"status"`
1370+
Iterations []*TapdIteration `bson:"iterations" json:"iterations" yaml:"iterations"`
13701371
}
13711372

13721373
type WorkflowTriggerJobSpec struct {

pkg/microservice/aslan/core/system/handler/tapd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ func ListTapdProjectIterations(c *gin.Context) {
5454

5555
id := c.Param("id")
5656
projectID := c.Param("projectID")
57-
ctx.Resp, ctx.RespErr = service.ListTapdIterations(id, projectID)
57+
status := c.Query("status")
58+
ctx.Resp, ctx.RespErr = service.ListTapdIterations(id, projectID, status)
5859
}

pkg/microservice/aslan/core/system/service/tapd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func ListTapdProjects(id string) ([]*tapd.Workspace, error) {
4040
return projectList, nil
4141
}
4242

43-
func ListTapdIterations(id, projectID string) ([]*tapd.Iteration, error) {
43+
func ListTapdIterations(id, projectID, status string) ([]*tapd.Iteration, error) {
4444
spec, err := mongodb.NewProjectManagementColl().GetTapdSpec(id)
4545
if err != nil {
4646
return nil, err
@@ -51,7 +51,7 @@ func ListTapdIterations(id, projectID string) ([]*tapd.Iteration, error) {
5151
return nil, err
5252
}
5353

54-
iterations, err := client.ListIterations(projectID)
54+
iterations, err := client.ListIterations(projectID, status)
5555
if err != nil {
5656
return nil, err
5757
}

pkg/tool/tapd/client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func (c *TapdClient) GetIterationCount(projectID string) (int, error) {
189189
return count.Count, nil
190190
}
191191

192-
func (c *TapdClient) ListIterations(projectID string) ([]*Iteration, error) {
192+
func (c *TapdClient) ListIterations(projectID, status string) ([]*Iteration, error) {
193193
count, err := c.GetIterationCount(projectID)
194194
if err != nil {
195195
return nil, fmt.Errorf("failed to get iteration count: %w", err)
@@ -211,6 +211,10 @@ func (c *TapdClient) ListIterations(projectID string) ([]*Iteration, error) {
211211
"workspace_id": projectID,
212212
}
213213

214+
if status != "" {
215+
queryParams["status"] = status
216+
}
217+
214218
result := &Response{}
215219
resp, err := httpclient.Get(iterationURL,
216220
httpclient.SetHeader("Authorization", fmt.Sprintf("Bearer %s", c.AccessToken)),

0 commit comments

Comments
 (0)