2020-02-29 00:49:55 +01:00
|
|
|
package model
|
|
|
|
|
2020-03-06 19:54:52 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
2020-03-05 20:42:25 +01:00
|
|
|
// ToDo: add key-value extra params as a map to allow for customfield_whatever = team
|
2020-02-29 00:49:55 +01:00
|
|
|
type Campaign struct {
|
2020-03-05 21:31:20 +01:00
|
|
|
Url string `json:"url"`
|
|
|
|
Project string `json:"project"`
|
|
|
|
Epic string `json:"epic"`
|
|
|
|
IssueType string `json:"issue_type"`
|
|
|
|
Summary string `json:"summary"`
|
|
|
|
Template string `json:"template"`
|
|
|
|
Tickets []*Ticket `json:"tickets,omitempty"`
|
2020-02-29 00:49:55 +01:00
|
|
|
}
|
2020-03-05 22:37:01 +01:00
|
|
|
|
2020-03-07 13:27:11 +01:00
|
|
|
func (c *Campaign) NextJiraUnpublishedTicket() *Ticket {
|
2020-03-05 22:37:01 +01:00
|
|
|
for _, ticket := range c.Tickets {
|
|
|
|
if ticket.JiraLink == "" {
|
|
|
|
return ticket
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2020-03-06 19:54:52 +01:00
|
|
|
|
2020-03-07 13:27:11 +01:00
|
|
|
func (c *Campaign) NextGithubUnpublishedTicket() *Ticket {
|
|
|
|
for _, ticket := range c.Tickets {
|
|
|
|
if ticket.JiraLink != "" && ticket.GithubLink != 0 {
|
|
|
|
return ticket
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-03-06 19:54:52 +01:00
|
|
|
func (c *Campaign) PrintStatus(w io.Writer) {
|
|
|
|
fmt.Fprintf(w, "Url: %s\n", c.Url)
|
|
|
|
fmt.Fprintf(w, "Project: %s\n", c.Project)
|
|
|
|
fmt.Fprintf(w, "Epic: %s\n", c.Epic)
|
|
|
|
fmt.Fprintf(w, "Issue Type: %s\n", c.IssueType)
|
|
|
|
fmt.Fprintf(w, "Summary: %s\n", c.Summary)
|
|
|
|
fmt.Fprintf(w, "Template: %s\n", c.Template)
|
|
|
|
|
|
|
|
for _, ticket := range c.Tickets {
|
|
|
|
ticket.PrintStatus(w)
|
|
|
|
}
|
|
|
|
}
|