Skip to content

Commit

Permalink
Merge pull request #8 from gennaro-tedesco/updated_at
Browse files Browse the repository at this point in the history
added updated_at in details
  • Loading branch information
Gennaro Tedesco authored Feb 4, 2022
2 parents c7ce4da + 7299e9c commit 80ca519
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import (
)

type issueInfo struct {
Title string
URL string
State string
Labels []interface{}
Title string
URL string
State string
Labels []interface{}
UpdatedAt string
}

func getIssues(query url.Values) []issueInfo {
Expand All @@ -33,10 +34,11 @@ func getIssues(query url.Values) []issueInfo {
for _, item := range itemsResults {
if item.(map[string]interface{})["pull_request"] == nil {
issues = append(issues, issueInfo{
Title: item.(map[string]interface{})["title"].(string),
URL: item.(map[string]interface{})["html_url"].(string),
State: item.(map[string]interface{})["state"].(string),
Labels: item.(map[string]interface{})["labels"].([]interface{}),
Title: item.(map[string]interface{})["title"].(string),
URL: item.(map[string]interface{})["html_url"].(string),
State: item.(map[string]interface{})["state"].(string),
Labels: item.(map[string]interface{})["labels"].([]interface{}),
UpdatedAt: item.(map[string]interface{})["updated_at"].(string),
})
}
}
Expand Down
7 changes: 7 additions & 0 deletions cmd/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/url"
"os"
"strings"
"time"

"github.com/jedib0t/go-pretty/v6/table"
"github.com/jedib0t/go-pretty/v6/text"
Expand Down Expand Up @@ -139,6 +140,11 @@ func getTemplate(colour string) *promptui.SelectTemplates {
return urlSlice[3] + "/" + urlSlice[4]
}

funcMap["parseTimestamp"] = func(UpdatedAt string) string {
t, _ := time.Parse("2006-01-02T15:04:05Z", UpdatedAt)
return t.Format("2006-01-02 15:04:05")
}

return &promptui.SelectTemplates{
Active: fmt.Sprintf("\U0001F449 {{ .Title | %s | bold }} {{ .State | faint }}", colour),
Inactive: fmt.Sprintf(" {{ .Title | %s }}", colour),
Expand All @@ -147,6 +153,7 @@ func getTemplate(colour string) *promptui.SelectTemplates {
{{ "Repository:" | faint }} {{ .URL | getRepoName }}
{{ "Url address:" | faint }} {{ .URL }}
{{ "Labels:" | faint }} {{ .Labels | parseLabels }}
{{ "Last updated:" | faint }} {{ .UpdatedAt | parseTimestamp }}
`,
}

Expand Down

0 comments on commit 80ca519

Please # to comment.