Skip to content

Commit 9bb547f

Browse files
authored
fix(workflow): Move description filter for workflows (#1589)
Signed-off-by: Javier Rodriguez <[email protected]>
1 parent a98686c commit 9bb547f

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

app/controlplane/pkg/biz/workflow_integration_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,28 @@ func (s *workflowListIntegrationTestSuite) TestList() {
358358
s.Len(workflows, 1)
359359
})
360360

361+
s.Run("list workflows with description filter", func() {
362+
_, err := s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{OrgID: s.org.ID, Name: "name1", Project: project, Team: team, Description: description})
363+
require.NoError(s.T(), err)
364+
_, err = s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{OrgID: s.org.ID, Name: "name2", Project: project, Team: team, Description: "this is a different description"})
365+
require.NoError(s.T(), err)
366+
367+
workflows, _, err := s.Workflow.List(ctx, s.org.ID, &biz.WorkflowListOpts{WorkflowDescription: "different"}, nil)
368+
s.NoError(err)
369+
s.Len(workflows, 1)
370+
})
371+
372+
s.Run("list workflows with description and workflow name filter", func() {
373+
_, err := s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{OrgID: s.org.ID, Name: "name1", Project: project, Team: team, Description: description})
374+
require.NoError(s.T(), err)
375+
_, err = s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{OrgID: s.org.ID, Name: "name2", Project: project, Team: team, Description: "this is a different description for name2"})
376+
require.NoError(s.T(), err)
377+
378+
workflows, _, err := s.Workflow.List(ctx, s.org.ID, &biz.WorkflowListOpts{WorkflowName: "name2", WorkflowDescription: "name2"}, nil)
379+
s.NoError(err)
380+
s.Len(workflows, 1)
381+
})
382+
361383
s.Run("list workflows with workflow team filter", func() {
362384
_, err := s.Workflow.Create(ctx, &biz.WorkflowCreateOpts{OrgID: s.org.ID, Name: "name1", Project: project, Team: team, Description: description})
363385
require.NoError(s.T(), err)

app/controlplane/pkg/data/workflow.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,6 @@ func applyWorkflowFilters(wfQuery *ent.WorkflowQuery, opts *biz.WorkflowListOpts
229229
)
230230
}
231231

232-
if opts.WorkflowDescription != "" {
233-
wfQuery = wfQuery.Where(workflow.DescriptionContains(opts.WorkflowDescription))
234-
}
235-
236232
if len(opts.WorkflowProjectNames) != 0 {
237233
wfQuery = wfQuery.Where(workflow.HasProjectWith(project.NameIn(opts.WorkflowProjectNames...)))
238234
}
@@ -246,6 +242,10 @@ func applyWorkflowFilters(wfQuery *ent.WorkflowQuery, opts *biz.WorkflowListOpts
246242
orConditions = append(orConditions, workflow.NameContains(opts.WorkflowName))
247243
}
248244

245+
if opts.WorkflowDescription != "" {
246+
wfQuery = wfQuery.Where(workflow.DescriptionContains(opts.WorkflowDescription))
247+
}
248+
249249
if len(orConditions) > 0 {
250250
wfQuery = wfQuery.Where(workflow.Or(orConditions...))
251251
}

0 commit comments

Comments
 (0)