Esempio n. 1
0
func getAppDeployCount(q Query, client *flowdock.Client, channel chan AppDeployCount) {
	var deployCount = map[string]int{}

	go func() {

		app := q.Tags[len(q.Tags)-1]
		opt := flowdock.MessagesListOptions{Limit: 100, TagMode: "and"}

		opt.Tags = q.Tags
		opt.Search = "production to production"
		opt.Event = "mail"

		messages, _, err := client.Messages.List(q.Org, q.Flow, &opt)

		if err != nil {
			log.Fatal("Get:", err)
		}

		total := 0
		for _, msg := range messages {
			if !stringInSlice("preproduction", *msg.Tags) {
				total++
				month := msg.Sent.Format("2006-Jan")
				deployCount[month]++
				// fmt.Println("MSG:", month, *msg.ID, *msg.Event, *msg.Tags)
			}
		}

		if len(messages) == limit {
			removeEarliestMonth(&deployCount)
		}

		channel <- AppDeployCount{app, total, &deployCount}
	}()
}
Esempio n. 2
0
func messageSearch(tags *[]string, event, search *string, client *flowdock.Client) {
	opt := flowdock.MessagesListOptions{Limit: 100, TagMode: "and"}
	if tags != nil {
		opt.Tags = *tags
	}
	if search != nil {
		opt.Search = *search
	}
	if event != nil {
		opt.Event = *event
	}
	messages, _, err := client.Messages.List("iora", "tech-stuff", &opt)

	if err != nil {
		log.Fatal("Get:", err)
	}

	for _, msg := range messages {
		displayMessageData(msg)
	}
	fmt.Println("Count:", len(messages))
}