Created
December 18, 2017 14:31
-
-
Save jmbejar/fbe6ac8cd6c9c1b06af4045101c82d98 to your computer and use it in GitHub Desktop.
Script to wrap up our remote retrospectives in Trello Raw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'trello' | |
require 'date' | |
Trello.configure do |config| | |
config.developer_public_key = "[PUBLIC_KEY]" | |
config.member_token = "[MEMBER_TOKEN]" | |
end | |
class RetrospectiveSummary | |
def initialize(board_id:) | |
@board_id = board_id | |
@summary = '' | |
end | |
def run | |
process_lists | |
create_summary_card | |
end | |
private | |
def process_lists | |
lists = [ | |
'Level of Motivation', 'Peter', 'Samuel', 'Carl', 'Julie', | |
'Good', 'To improve', 'Idea', 'Action plan' | |
] | |
lists.each do |title| | |
add_section_title_to_summary(title) | |
list = list_by_title(title) | |
list.cards.each do |post| | |
add_post_to_summary(post) | |
post.close! unless title == 'Action plan' | |
end | |
end | |
end | |
def create_summary_card | |
retro_date = (Date.today - 14).strftime("%B %d") | |
history_list = list_by_title('History') | |
Trello::Card.create({ | |
name: "Retro #{retro_date}", | |
desc: @summary, | |
list_id: history_list.attributes[:id], | |
pos: 'top' | |
}) | |
end | |
def board | |
@board ||= Trello::Board.find(@board_id) | |
end | |
def list_by_title(title) | |
board.lists.find { |x| x.name == title } | |
end | |
def add_section_title_to_summary(title) | |
@summary += "\n## #{title}\n" | |
end | |
def add_post_to_summary(post) | |
@summary += "- [#{post.labels.first.try(:color)}] #{post.name}\n" | |
end | |
end | |
RetrospectiveSummary.new(board_id: "[BOARD_ID]").run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment