Skip to content

Commit

Permalink
fix(#95): bad request error when use filter-by-assignee together with…
Browse files Browse the repository at this point in the history
… Jira Cloud API
  • Loading branch information
mk-5 committed Jan 22, 2024
1 parent 46ae0f1 commit 3b53aaa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/issues/jql_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions internal/issues/jql_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3b53aaa

Please sign in to comment.