Adding more states to the status command

This commit is contained in:
Miguel de la Cruz 2020-09-24 13:41:48 +02:00
parent 7b1b61a582
commit 177ed7fd6e
2 changed files with 18 additions and 3 deletions

View file

@ -54,12 +54,17 @@ func (c *Campaign) NextGithubUnpublishedTicket() *Ticket {
func (c *Campaign) PrintStatus() { func (c *Campaign) PrintStatus() {
totalTickets := len(c.Tickets) totalTickets := len(c.Tickets)
var totalPublishedJira, totalPublishedGithub int var totalPublishedJira, totalPublishedGithub, totalAssigned, totalClosed int
for _, t := range c.Tickets { for _, t := range c.Tickets {
if t.IsPublishedJira() { if t.IsPublishedJira() {
totalPublishedJira++ totalPublishedJira++
if t.IsPublishedGithub() { if t.IsPublishedGithub() {
totalPublishedGithub++ totalPublishedGithub++
if t.IsAssigned() {
totalAssigned++
} else if t.IsClosed() {
totalClosed++
}
} }
} }
} }
@ -67,7 +72,9 @@ func (c *Campaign) PrintStatus() {
fmt.Printf("Current campaign for %s with summary\n%s\n\n", color.GreenString(c.Github.Repo), color.CyanString(c.Summary)) fmt.Printf("Current campaign for %s with summary\n%s\n\n", color.GreenString(c.Github.Repo), color.CyanString(c.Summary))
fmt.Printf("\t%d\ttotal tickets\n", totalTickets) fmt.Printf("\t%d\ttotal tickets\n", totalTickets)
fmt.Printf("\t%d/%d\tpublished in Jira\n", totalPublishedJira, totalTickets) fmt.Printf("\t%d/%d\tpublished in Jira\n", totalPublishedJira, totalTickets)
fmt.Printf("\t%d/%d\tpublished in Github\n\n", totalPublishedGithub, totalPublishedJira) fmt.Printf("\t%d/%d\tpublished in Github\n", totalPublishedGithub, totalPublishedJira)
fmt.Printf("\t%d/%d\tassigned\n", totalAssigned, totalPublishedGithub)
fmt.Printf("\t%d/%d\tclosed\n\n", totalClosed, totalPublishedGithub)
} }
func (c *Campaign) AddTickets(tickets []*Ticket, fileOnly bool) { func (c *Campaign) AddTickets(tickets []*Ticket, fileOnly bool) {

View file

@ -20,7 +20,15 @@ func (t *Ticket) IsPublishedJira() bool {
} }
func (t *Ticket) IsPublishedGithub() bool { func (t *Ticket) IsPublishedGithub() bool {
return t.JiraLink != "" && t.GithubLink != 0 return t.IsPublishedJira() && t.GithubLink != 0
}
func (t *Ticket) IsAssigned() bool {
return t.IsPublishedGithub() && t.GithubAssignee != "" && t.GithubStatus == "open"
}
func (t *Ticket) IsClosed() bool {
return t.IsPublishedGithub() && t.GithubAssignee != "" && t.GithubStatus == "closed"
} }
func (t *Ticket) PrintStatus() { func (t *Ticket) PrintStatus() {