mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
add optional more advanced jql queries and working usernames
This commit is contained in:
parent
5035933f15
commit
b8ee0e56f6
@ -7,11 +7,31 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func IssuesFor(username string) (*SearchResult, error) {
|
||||
url := fmt.Sprintf("/rest/api/2/search?jql=assignee=%s", username)
|
||||
func IssuesFor(username string, project string, jql string) (*SearchResult, error) {
|
||||
query := []string{}
|
||||
|
||||
if project != "" {
|
||||
query = append(query, buildJql("project", project))
|
||||
}
|
||||
|
||||
if username != "" {
|
||||
query = append(query, buildJql("assignee", username))
|
||||
}
|
||||
|
||||
if jql != "" {
|
||||
query = append(query, jql)
|
||||
}
|
||||
|
||||
v := url.Values{}
|
||||
|
||||
v.Set("jql", strings.Join(query, " AND "))
|
||||
|
||||
url := fmt.Sprintf("/rest/api/2/search?%s", v.Encode())
|
||||
|
||||
resp, err := jiraRequest(url)
|
||||
if err != nil {
|
||||
@ -24,6 +44,10 @@ func IssuesFor(username string) (*SearchResult, error) {
|
||||
return searchResult, nil
|
||||
}
|
||||
|
||||
func buildJql(key string, value string) string {
|
||||
return fmt.Sprintf("%s = \"%s\"", key, value)
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func jiraRequest(path string) (*http.Response, error) {
|
||||
|
@ -29,7 +29,7 @@ func (widget *Widget) Refresh() {
|
||||
return
|
||||
}
|
||||
|
||||
searchResult, err := IssuesFor(Config.UString("wtf.mods.jira.username"))
|
||||
searchResult, err := IssuesFor(Config.UString("wtf.mods.jira.username"), Config.UString("wtf.mods.jira.project", ""), Config.UString("wtf.mods.jira.jql", ""))
|
||||
|
||||
widget.UpdateRefreshedAt()
|
||||
widget.View.Clear()
|
||||
|
Loading…
x
Reference in New Issue
Block a user