diff --git a/internal/issues/jql_builder.go b/internal/issues/jql_builder.go index afffaef..1cbc0b7 100644 --- a/internal/issues/jql_builder.go +++ b/internal/issues/jql_builder.go @@ -21,7 +21,11 @@ func BuildSearchIssuesJql(project *jira.Project, query string, status *jira.Issu jql = jql + fmt.Sprintf(" AND status=%s", status.Id) } if user != nil && user.DisplayName != ui.MessageAll { - jql = jql + fmt.Sprintf(" AND assignee=%s", user.AccountId) + userId := user.AccountId + if userId == "" { + userId = user.Name + } + jql = jql + fmt.Sprintf(" AND assignee=%s", userId) } // TODO - would be safer to check the index of inserted all message, instead of checking it like this / same for all All checks if label != "" && label != ui.MessageAll { diff --git a/internal/issues/jql_builder_test.go b/internal/issues/jql_builder_test.go index bf46b3d..ad67e9f 100644 --- a/internal/issues/jql_builder_test.go +++ b/internal/issues/jql_builder_test.go @@ -32,6 +32,7 @@ func Test_buildSearchIssuesJql(t *testing.T) { "project=123 AND summary~\"abc*\" AND status=st1 AND assignee=us1 ORDER BY status", }, {"should create valid jql", args{project: &jira.Project{Id: "123"}, label: "test"}, "project=123 AND labels=test ORDER BY status"}, + {"should create valid jql", args{project: &jira.Project{Id: "123"}, user: &jira.User{Name: "bob"}}, "project=123 AND assignee=bob ORDER BY status"}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {