From 177ed7fd6e6c585772e25452206bb1cbc7d13f01 Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Thu, 24 Sep 2020 13:41:48 +0200 Subject: [PATCH] Adding more states to the status command --- model/campaign.go | 11 +++++++++-- model/ticket.go | 10 +++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/model/campaign.go b/model/campaign.go index 2b46609..a6dc35b 100644 --- a/model/campaign.go +++ b/model/campaign.go @@ -54,12 +54,17 @@ func (c *Campaign) NextGithubUnpublishedTicket() *Ticket { func (c *Campaign) PrintStatus() { totalTickets := len(c.Tickets) - var totalPublishedJira, totalPublishedGithub int + var totalPublishedJira, totalPublishedGithub, totalAssigned, totalClosed int for _, t := range c.Tickets { if t.IsPublishedJira() { totalPublishedJira++ if t.IsPublishedGithub() { 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("\t%d\ttotal tickets\n", 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) { diff --git a/model/ticket.go b/model/ticket.go index 5738605..64af85e 100644 --- a/model/ticket.go +++ b/model/ticket.go @@ -20,7 +20,15 @@ func (t *Ticket) IsPublishedJira() 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() {