This repository has been archived by the owner on Mar 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
stories.rb
93 lines (73 loc) · 2.24 KB
/
stories.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env ruby
require 'tracker_api'
class ProjectCollection
def self.build(project_ids)
client = TrackerApi::Client.new(token: ENV["BOSH_NOTES_TRACKER_TOKEN"])
ProjectCollection.new(project_ids, client)
end
def initialize(project_ids, client)
@project_ids = project_ids
@client = client
end
def sorted
@project_ids.map { |id| @client.project(id) }
end
def print_md
colors = {
red: color_square("a72039"),
green: color_square("629100"),
orange: color_square("f39300"),
white: color_square("ffffff"),
blue: color_square("8bb1e0"),
}.freeze
state_to_text = {
"delivered" => colors[:green],
"finished" => colors[:orange],
"started" => colors[:blue],
"rejected" => colors[:red],
"planned" => "",
"unstarted" => "",
}.freeze
projects = sorted
puts "# Projects\n\n"
projects.each do |project|
puts "- [#{project.name}](https://www.pivotaltracker.com/projects/#{project.id})"
end
puts "# Stories\n\n"
projects.each do |project|
puts "## [#{project.name}](https://www.pivotaltracker.com/projects/#{project.id})\n\n"
# https://www.pivotaltracker.com/help/api/rest/v5#top
# accepted, delivered, finished, started, rejected, planned, unstarted, unscheduled
%w(delivered finished started rejected planned unstarted).each do |state|
stories = project.stories(with_state: state)
has_more_stories = false
if (state == "planned" || state == "unstarted") && stories.size > 10
stories = stories[0...10]
has_more_stories = true
end
puts "---" if state == "planned"
stories.each do |story|
puts "- #{state_to_text[state]} #{story.name} [link](https://www.pivotaltracker.com/story/show/#{story.id})"
end
puts "- ..." if has_more_stories
end
puts ""
end
end
private
def color_square(hex)
"![img](https://placehold.it/15/#{hex}/000000?text=+)"
end
end
wanted_project_ids = [
956238, # CF BOSH [DNS]
2139998, # CF BOSH [Links API]
2132440, # CF BOSH [Hotswap]
2132441, # CF BOSH
1133984, # CF BOSH CPI
1954971, # CF BOSH Extended Team
2140000, # CF BOSH [Interviews]
2110693, # BOSH vSphere CPI
1456570, # CF BOSH OpenStack CPI
]
ProjectCollection.build(wanted_project_ids).print_md