Skip to content

Commit f145113

Browse files
committed
Add a task for creating triage cards and reporting template
1 parent 8040fe8 commit f145113

File tree

5 files changed

+110
-5
lines changed

5 files changed

+110
-5
lines changed

kanboard_swimlane.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ def self.find_by_name(project_id, name)
1717
def move_to_position(index)
1818
connection.request('changeSwimlanePosition', [project_id, @id, index])
1919
end
20-
end
20+
end

kanboard_task.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ class KanboardTask < KanboardResource
55
GITHUB_URL = 'github.com'
66
BUGZILLA_URL = 'bugzilla.redhat.com'
77

8+
def self.create(params)
9+
id = connection.request('createTask', params)
10+
new connection.request('getTask', 'task_id' => id)
11+
end
12+
813
def redmine_links?
914
redmine_links.any?
1015
end
@@ -66,4 +71,8 @@ def set_complexity(complexity)
6671
def tags
6772
connection.request('getTaskTags', [@id]).map(&:last)
6873
end
69-
end
74+
75+
def owner
76+
KanboardUser.find_by_id(self.owner_id)
77+
end
78+
end

kanboard_user.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
require 'kanboard_resource'
22

33
class KanboardUser < KanboardResource
4-
def self.find_by_name( name)
4+
def self.find_by_name(name)
55
user = connection.request('getAllUsers').find { |u| u['name'] == name }
66
if user.nil?
77
Kansync.logger.error "Kanboard user with name #{name} not found, consider specifying mapping for this name"
88
return nil
99
else
10-
new connection, user
10+
new user
1111
end
1212
end
13-
end
13+
14+
def self.find_by_id(id)
15+
user = connection.request('getUser', 'user_id' => id)
16+
if user.nil?
17+
Kansync.logger.error "Kanboard user with id #{name} not found"
18+
return nil
19+
else
20+
new user
21+
end
22+
end
23+
end

tasks/910-new_triage_cards.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# default configuration
2+
task_configuration = {
3+
'users' => {
4+
# 'User' => 15
5+
},
6+
'color' => 'grey',
7+
'description' => 'Write here the BZ URLs that were triaged and final status:'
8+
}.merge(task_configuration)
9+
10+
existing_triage_title = project.search_tasks('status:open swimlane:"' + project.current_swimlane.name + '" column:"Backlog"').map(&:title)
11+
12+
task_configuration['users'].each do |user, count|
13+
new_title = "Triage 15 BZs - #{user} (0/#{count})"
14+
if existing_triage_title.include?(new_title)
15+
logger.debug "Skipping #{user} triage card, it's already there"
16+
else
17+
logger.info "Creating new triage card with title: #{new_title}"
18+
description = task_configuration['description'].to_s + "\n\n"
19+
description += "* \n" * count
20+
KanboardTask.create('title' => new_title, 'project_id' => project.id, 'color_id' => task_configuration['color'], 'description' => description, 'tags' => ['bz_triage'])
21+
end
22+
23+
logger.info "All new triage cards created"
24+
end
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# default configuration
2+
task_configuration = {
3+
'users' => {
4+
# 'User' => 15
5+
},
6+
'ignore_patterns' => [],
7+
}.merge(task_configuration)
8+
9+
10+
data_to_report = {}
11+
unassigned = []
12+
logger.info "starting to process data, this can take some time"
13+
project.current_tasks.each do |task|
14+
logger.debug "processing #{task.title}"
15+
tags = task.tags.empty? ? '' : ' ' + task.tags.map {|t| "##{t}" }.join(' ')
16+
title = task.title + tags
17+
18+
if task.assignee_name.nil?
19+
unassigned << title
20+
next
21+
end
22+
23+
owner = task.assignee_name.split(' ').first
24+
data_to_report[owner] ||= { 'done' => [], 'iteration' => [], 'review' => []}
25+
26+
case task.column_name
27+
when 'Done'
28+
data_to_report[owner]['done'] << title
29+
else
30+
data_to_report[owner]['iteration'] << title
31+
end
32+
33+
if (match_data = title.match(/.* - \[(.*)\]/))
34+
reviewer = match_data[1]
35+
data_to_report[reviewer] ||= { 'done' => [], 'iteration' => [], 'review' => []}
36+
data_to_report[reviewer]['review'] << title
37+
end
38+
end
39+
40+
logger.info "generating the template"
41+
42+
data_to_report.each do |owner, tasks|
43+
puts "==#{owner}=="
44+
puts "Iteration items:"
45+
tasks['iteration'].each do |item|
46+
puts "* #{item}"
47+
end
48+
49+
puts "Done items:"
50+
tasks['done'].each do |item|
51+
puts "* #{item}"
52+
end
53+
54+
puts "Review items:"
55+
tasks['review'].each do |item|
56+
puts "* #{item}"
57+
end
58+
59+
puts "Other items:"
60+
puts "Plan:"
61+
puts ""
62+
end

0 commit comments

Comments
 (0)