Skip to content

Commit 88d212f

Browse files
committed
code-review fixes:
- API error, because of wrong key - remove colors, because that is handled by C3 - add usernames, not user IDs - add 'TR-' notation
1 parent 439861c commit 88d212f

File tree

2 files changed

+44
-52
lines changed

2 files changed

+44
-52
lines changed

tcms/telemetry/api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def performance_telemetry(query=None):
261261
# count only execution which are finished
262262
.exclude(status__weight=0)
263263
.order_by("run_id")
264-
.values("assignee_id", "run_id")
264+
.values("assignee_id", "run_id", "assignee__username")
265265
)
266266

267267
result = {}
@@ -271,7 +271,7 @@ def performance_telemetry(query=None):
271271
run_id = execution["run_id"]
272272

273273
assignee_count = {}
274-
assignee = execution["assignee_id"]
274+
assignee = execution["assignee__username"] or ""
275275
if assignee in assignee_count:
276276
assignee_count[assignee] = assignee_count[assignee] + 1
277277
else:
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
// TODO: account for more users
2-
const colors = [
3-
'blue',
4-
'red',
5-
'gold',
6-
'orange',
7-
'green',
8-
'cyan',
9-
'purple',
10-
'black',
11-
'lightBlue',
12-
'lightGreen'
13-
]
14-
151
$(document).ready(() => {
162
$('.selectpicker').selectpicker()
173
$('[data-toggle="tooltip"]').tooltip()
@@ -35,7 +21,7 @@ function reloadCharts () {
3521
if (testPlanIds.length) {
3622
query.plan__in = testPlanIds
3723
} else if (productIds.length) {
38-
query.category__product_id__in = productIds
24+
query.case__category__product_id__in = productIds
3925
}
4026

4127
const dateBefore = $('#id_before')
@@ -53,58 +39,64 @@ function reloadCharts () {
5339

5440
// the actual result is in the same format, only it can be much bigger
5541
// and the chart may break
56-
const r = {
57-
1: {
58-
1: 1,
59-
3: 2
60-
},
61-
2: {
62-
1: 1,
63-
4: 2
64-
},
65-
3: {
66-
1: 1,
67-
3: 1,
68-
5: 1
69-
},
70-
4: {
71-
3: 1,
72-
2: 1
73-
},
74-
5: {
75-
1: 5,
76-
3: 2,
77-
4: 1
78-
}
79-
}
80-
81-
drawChart(r)
42+
// const r = {
43+
// 1: {
44+
// "asankov": 1,
45+
// "atodorov": 2
46+
// },
47+
// 2: {
48+
// "asankov": 1,
49+
// "atodorov": 2
50+
// },
51+
// 3: {
52+
// "asankov": 1,
53+
// "atodorov": 1,
54+
// "": 1
55+
// },
56+
// 4: {
57+
// "asankov": 1,
58+
// "atodorov": 1
59+
// },
60+
// 5: {
61+
// "asankov": 5,
62+
// "atodorov": 2,
63+
// "bot": 1
64+
// }
65+
// }
66+
67+
drawChart(result)
8268
}, true)
8369
}
8470

8571
function drawChart (data) {
8672
// the X axis of the chart - run IDs
8773
const groupedCategories = []
88-
// map of user ID -> table column. we use map here for faster lookup by user ID.
74+
// map of username -> table column. we use map here for faster lookup by username.
8975
const groupedColumnsDataMap = {}
90-
const userIds = new Set()
76+
const usernames = new Set()
9177

9278
// collect all the testers so that we know how much columns we will have
9379
Object.entries(data).forEach(([_testRunId, asigneeCount]) => {
94-
Object.entries(asigneeCount).forEach(([userId, _executionCount]) => userIds.add(userId))
80+
Object.entries(asigneeCount).forEach(([username, _executionCount]) => {
81+
// filter empty users
82+
// TODO: maybe we can do that on the API level
83+
if (username) {
84+
usernames.add(username)
85+
}
86+
})
9587
})
9688

97-
userIds.forEach(userId => (groupedColumnsDataMap[userId] = [`User ${userId}`]))
89+
usernames.forEach(username => (groupedColumnsDataMap[username] = [username]))
9890

9991
Object.entries(data).forEach(([testRunId, _asigneeCount]) => {
100-
groupedCategories.push(testRunId)
92+
groupedCategories.push(`TR-${testRunId}`)
10193

10294
const asigneesCount = data[testRunId]
10395

10496
// for each user in the groupedColumnsDataMap check if that user
10597
// is assigned any executions for this run.
106-
Object.entries(groupedColumnsDataMap).forEach(([userId, data]) => {
107-
const count = asigneesCount[userId]
98+
Object.entries(groupedColumnsDataMap).forEach(([username, data]) => {
99+
const count = asigneesCount[username]
108100
if (count) {
109101
data.push(count)
110102
} else {
@@ -135,8 +127,8 @@ function drawChart (data) {
135127
type: 'bar',
136128
columns: groupedColumnsData
137129
}
138-
chartConfig.color = {
139-
pattern: colors
130+
chartConfig.zoom = {
131+
enabled: true
140132
}
141133
c3.generate(chartConfig)
142134
}

0 commit comments

Comments
 (0)