Some cleanup
This commit is contained in:
parent
d3386d4a58
commit
4f44943d90
7 changed files with 90 additions and 19 deletions
|
|
@ -7,9 +7,9 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
//curl -u olivier@circleci.com:"$(cat ~/jiratoken)" 'https://circleci.atlassian.net/rest/api/2/search?jql=sprint+in+openSprints()+and+project=CIAM'
|
||||
"github.com/eliziario/jira-lib/pkg/adf"
|
||||
)
|
||||
|
||||
var jcl = http.Client{}
|
||||
|
||||
|
|
@ -88,6 +88,7 @@ func GetIssues(instance, user, from, to string) ([]Issue, error) {
|
|||
q := req.URL.Query()
|
||||
q.Add("jql", fmt.Sprintf("assignee was %s and resolved >= %s and resolved <= %s", accountID, from, to))
|
||||
q.Add("fields", "*all")
|
||||
q.Add("expand", "renderedFields")
|
||||
req.URL.RawQuery = q.Encode()
|
||||
req.SetBasicAuth(os.Getenv("JIRA_USER"), os.Getenv("JIRA_TOKEN"))
|
||||
req.Header.Add("Accept", "application/json")
|
||||
|
|
@ -116,7 +117,8 @@ func GetIssues(instance, user, from, to string) ([]Issue, error) {
|
|||
iss.Summary, _ = s.(string)
|
||||
}
|
||||
if d, ok := i.Fields["description"]; ok {
|
||||
iss.Description, _ = d.(string)
|
||||
doc := ifaceToADF(d)
|
||||
iss.Description = adf.NewTranslator(doc, adf.NewMarkdownTranslator()).Translate()
|
||||
}
|
||||
if comms, ok := i.Fields["comment"].([]map[string]any); ok && len(comms) > 0 {
|
||||
iss.Comments = make([]Comment, 0, len(comms))
|
||||
|
|
@ -131,3 +133,20 @@ func GetIssues(instance, user, from, to string) ([]Issue, error) {
|
|||
|
||||
return out, nil
|
||||
}
|
||||
func ifaceToADF(v any) *adf.ADF {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var doc *adf.ADF
|
||||
|
||||
js, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return nil // ignore invalid data
|
||||
}
|
||||
if err = json.Unmarshal(js, &doc); err != nil {
|
||||
return nil // ignore invalid data
|
||||
}
|
||||
|
||||
return doc
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue