Skip to content

Commit

Permalink
issue view - allow searching for string in title
Browse files Browse the repository at this point in the history
  • Loading branch information
3ximus committed Feb 25, 2024
1 parent ac24dc7 commit 16dd461
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion api/jira-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func GetIssue(key string) <-chan JiraIssue {
return channel
}

func GetIssueList(nResults int, all bool, reporter bool, project string, statuses []string, prioritySort bool) <-chan JiraIssue {
func GetIssueList(nResults int, all bool, reporter bool, project string, statuses []string, searchTerm string, prioritySort bool) <-chan JiraIssue {
channel := make(chan JiraIssue)
go func() {
defer close(channel)
Expand All @@ -111,6 +111,12 @@ func GetIssueList(nResults int, all bool, reporter bool, project string, statuse
}
query += fmt.Sprintf("project=%s", url.QueryEscape(project))
}
if searchTerm != "" {
if query != "" {
query += "+AND+"
}
query += fmt.Sprintf("summary~\"%s\"", url.QueryEscape(searchTerm))
}
if len(statuses) > 0 {
if query != "" {
query += "+AND+"
Expand Down
5 changes: 4 additions & 1 deletion cmd/issue/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var ListCmd = &cobra.Command{
nResults, _ := cmd.Flags().GetInt("number-results")
reporter, _ := cmd.Flags().GetBool("reporter")
all, _ := cmd.Flags().GetBool("all")
search, _ := cmd.Flags().GetString("search")
statuses, _ := cmd.Flags().GetStringArray("status")
project, _ := cmd.Flags().GetString("project")
priority, _ := cmd.Flags().GetBool("priority")
Expand Down Expand Up @@ -50,7 +51,7 @@ var ListCmd = &cobra.Command{
}
}

for issue := range api.GetIssueList(nResults, all, reporter, project, statusConversion, priority) {
for issue := range api.GetIssueList(nResults, all, reporter, project, statusConversion, search, priority) {
timeSpent := "-"
if issue.Fields.TimeTracking.TimeSpent != " " {
timeSpent = issue.Fields.TimeTracking.TimeSpent
Expand All @@ -74,13 +75,15 @@ var ListCmd = &cobra.Command{
}

func init() {
// filter
ListCmd.Flags().StringP("project", "p", "", `filter issues by project key.
If "all" is given it shows all projects (when a project is detected on current branch and you still want to show all projects)`)
ListCmd.Flags().BoolP("all", "a", false, "filter all issues. (Not assigned or reporting to current user)")
ListCmd.Flags().BoolP("reporter", "r", false, "filter issues reporting to current user")
ListCmd.Flags().StringArrayP("status", "s", []string{}, `filter status type.
this option will provide completion for the mappings defined in "jira_status" of your config file`)
ListCmd.RegisterFlagCompletionFunc("status", statusCompletion)
ListCmd.Flags().String("search", "", "filter issues by keyword")

// TODO add way to sort by recent or the ones the user has participated on

Expand Down

0 comments on commit 16dd461

Please sign in to comment.