Merge lp:~toykeeper/qakit/add-actions-report into lp:~thomir-deactivatedaccount/qakit/trunk

Proposed by Selene ToyKeeper
Status: Merged
Merged at revision: 4
Proposed branch: lp:~toykeeper/qakit/add-actions-report
Merge into: lp:~thomir-deactivatedaccount/qakit/trunk
Diff against target: 145 lines (+98/-0)
3 files modified
qakit/commands.py (+4/-0)
qakit/format.py (+47/-0)
qakit/trello.py (+47/-0)
To merge this branch: bzr merge lp:~toykeeper/qakit/add-actions-report
Reviewer Review Type Date Requested Status
Thomi Richards Pending
Review via email: mp+237531@code.launchpad.net

Commit message

Added a basic report of card actions each person did over the past two weeks.

Description of the change

Added a basic report of card actions each person did over the past two weeks.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qakit/commands.py'
2--- qakit/commands.py 2014-10-08 01:30:28 +0000
3+++ qakit/commands.py 2014-10-08 04:53:08 +0000
4@@ -31,8 +31,12 @@
5 "backlog.")
6 subparsers.add_parser("silo-stats", help="Show statistics around completed "
7 "silo testing.")
8+ subparsers.add_parser("silo-actions", help="Show statistics about overall "
9+ "activity per person.")
10 args = parser.parse_args()
11 if args.command == 'silo-backlog':
12 trello.silo_backlog()
13 elif args.command == 'silo-stats':
14 trello.silo_stats()
15+ elif args.command == 'silo-actions':
16+ trello.silo_actions()
17
18=== modified file 'qakit/format.py'
19--- qakit/format.py 2014-10-08 01:30:28 +0000
20+++ qakit/format.py 2014-10-08 04:53:08 +0000
21@@ -53,6 +53,53 @@
22 print(tbl)
23
24
25+def print_actions_table(actions):
26+ raw_actions = actions
27+ actions = []
28+ #period = _get_one_week_ago()
29+ period = _get_one_fortnight_ago()
30+ for a in raw_actions:
31+ if period.contains(a.when):
32+ actions.append(a)
33+
34+ # populate 'fields' and 'people'
35+ fields = ['Name']
36+ people = {}
37+ for a in actions:
38+ if a.what not in fields:
39+ fields.append(a.what)
40+ if a.who not in people:
41+ people[a.who] = {'updateCard':0, 'commentCard':0}
42+ if a.what not in people[a.who]:
43+ people[a.who][a.what] = 0
44+ people[a.who][a.what] += 1
45+ fields.sort()
46+ # put these fields first
47+ fields.remove('updateCard')
48+ fields.insert(1, 'updateCard')
49+ fields.remove('commentCard')
50+ fields.insert(2, 'commentCard')
51+
52+ foo = [(-v['updateCard'],-v['commentCard'],k,v) for k,v in people.items()]
53+ foo.sort()
54+ people = [(x[-2],x[-1]) for x in foo]
55+
56+ tbl = prettytable.PrettyTable(fields)
57+ tbl.align["Name"] = 'l'
58+
59+ for person, actions in people:
60+ row = []
61+ row.append(termcolor.colored(person, **_card_title_opts))
62+ for f in fields[1:]:
63+ amount = 0
64+ if f in actions:
65+ amount = actions[f]
66+ row.append(termcolor.colored(str(amount), **_card_lane_opts))
67+ tbl.add_row(row)
68+
69+ print(tbl)
70+
71+
72 def print_last_day_stats(cards):
73 print_title("Last 24 Hours:")
74 period = _get_24_hours_ago()
75
76=== modified file 'qakit/trello.py'
77--- qakit/trello.py 2014-10-08 01:30:28 +0000
78+++ qakit/trello.py 2014-10-08 04:53:08 +0000
79@@ -55,6 +55,17 @@
80 self.name = name
81
82
83+class CardAction(object):
84+ who = u''
85+ what = u''
86+ when = u''
87+
88+ def __init__(self, who, what, when):
89+ self.who = who
90+ self.what = what
91+ self.when = when
92+
93+
94 def silo_backlog():
95 api = trello.TrelloApi(TRELLO_API_KEY)
96 open_cards = _get_open_cards(lambda: _get_all_silo_cards(api))
97@@ -69,6 +80,14 @@
98 format.print_last_week_stats(cards)
99 format.print_meta_stats(cards)
100
101+
102+def silo_actions():
103+ api = trello.TrelloApi(TRELLO_API_KEY)
104+ actions = _get_all_actions(api)
105+ format.print_title("Activity Summary:")
106+ format.print_actions_table(actions)
107+
108+
109 def test():
110 api = trello.TrelloApi(TRELLO_API_KEY)
111
112@@ -102,6 +121,34 @@
113 yield c
114
115
116+def _get_all_actions(trello_api):
117+ actions = []
118+ raw_actions = trello_api.boards.get_action(
119+ TRELLO_SILO_TEST_BOARD,
120+ limit=1000
121+ )
122+ for action in raw_actions:
123+ list_before = action[u'data'].get('listBefore', None)
124+ list_after = action[u'data'].get('listAfter', None)
125+ user_name = action[u'memberCreator'][u'fullName']
126+ time_string = action[u'date']
127+ time_stamp = dateutil.parser.parse(time_string)
128+
129+ act = action[u'type']
130+
131+ # skip a few action types
132+ if act in ('createCard','deleteCard','removeMemberFromCard',
133+ 'updateBoard',):
134+ continue
135+ # ignore updates which don't traverse lanes
136+ # (not entirely sure what all these actions are though)
137+ if act == 'updateCard' and (None in (list_before, list_after)):
138+ continue
139+
140+ a = CardAction(user_name, act, time_stamp)
141+ yield a
142+
143+
144 def _get_all_silo_cards(trello_api):
145 """Get a list of cards that are in the 'awaiting QA signoff' lane.
146

Subscribers

People subscribed via source and target branches

to all changes: