Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Support multiple queues via --queue" #16

Merged
merged 1 commit into from
Dec 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"log"
"os"
"regexp"
"strings"
"time"

"gopkg.in/buildkite/go-buildkite.v2/buildkite"
Expand All @@ -33,7 +32,7 @@ func main() {
version = flag.Bool("version", false, "Show the version")

// filters
queues = flag.String("queue", "", "Filter by list of queues, comma delimited")
queue = flag.String("queue", "", "Only include a specific queue")
)

flag.Parse()
Expand Down Expand Up @@ -65,7 +64,7 @@ func main() {
res, err := collectResults(client, collectOpts{
OrgSlug: *orgSlug,
Historical: *history,
Queues: strings.Split(*queues, ","),
Queue: *queue,
})
if err != nil {
return err
Expand Down Expand Up @@ -98,7 +97,7 @@ func main() {
type collectOpts struct {
OrgSlug string
Historical time.Duration
Queues []string
Queue string
}

func collectResults(client *buildkite.Client, opts collectOpts) (*result, error) {
Expand All @@ -108,7 +107,7 @@ func collectResults(client *buildkite.Client, opts collectOpts) (*result, error)
pipelines: map[string]counts{},
}

if len(opts.Queues) == 0 {
if opts.Queue == "" {
log.Println("Collecting historical metrics")
if err := res.addHistoricalMetrics(client, opts); err != nil {
return nil, err
Expand All @@ -125,19 +124,18 @@ func collectResults(client *buildkite.Client, opts collectOpts) (*result, error)
return nil, err
}

if len(opts.Queues) == 0 {
return res, nil
}

filteredRes := &result{
queues: map[string]counts{},
}

for _, queue := range opts.Queues {
filteredRes.queues[queue] = res.queues[queue]
if opts.Queue != "" {
if c, ok := res.queues[opts.Queue]; ok {
return &result{
queues: map[string]counts{
opts.Queue: c,
},
}, nil
}
return &result{}, nil
}

return filteredRes, nil
return res, nil
}

func dumpResults(res *result) {
Expand Down