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
-
15
1
$ ( document ) . ready ( ( ) => {
16
2
$ ( '.selectpicker' ) . selectpicker ( )
17
3
$ ( '[data-toggle="tooltip"]' ) . tooltip ( )
@@ -35,7 +21,7 @@ function reloadCharts () {
35
21
if ( testPlanIds . length ) {
36
22
query . plan__in = testPlanIds
37
23
} else if ( productIds . length ) {
38
- query . category__product_id__in = productIds
24
+ query . case__category__product_id__in = productIds
39
25
}
40
26
41
27
const dateBefore = $ ( '#id_before' )
@@ -53,58 +39,64 @@ function reloadCharts () {
53
39
54
40
// the actual result is in the same format, only it can be much bigger
55
41
// 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 )
82
68
} , true )
83
69
}
84
70
85
71
function drawChart ( data ) {
86
72
// the X axis of the chart - run IDs
87
73
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 .
89
75
const groupedColumnsDataMap = { }
90
- const userIds = new Set ( )
76
+ const usernames = new Set ( )
91
77
92
78
// collect all the testers so that we know how much columns we will have
93
79
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
+ } )
95
87
} )
96
88
97
- userIds . forEach ( userId => ( groupedColumnsDataMap [ userId ] = [ `User ${ userId } ` ] ) )
89
+ usernames . forEach ( username => ( groupedColumnsDataMap [ username ] = [ username ] ) )
98
90
99
91
Object . entries ( data ) . forEach ( ( [ testRunId , _asigneeCount ] ) => {
100
- groupedCategories . push ( testRunId )
92
+ groupedCategories . push ( `TR- ${ testRunId } ` )
101
93
102
94
const asigneesCount = data [ testRunId ]
103
95
104
96
// for each user in the groupedColumnsDataMap check if that user
105
97
// 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 ]
108
100
if ( count ) {
109
101
data . push ( count )
110
102
} else {
@@ -135,8 +127,8 @@ function drawChart (data) {
135
127
type : 'bar' ,
136
128
columns : groupedColumnsData
137
129
}
138
- chartConfig . color = {
139
- pattern : colors
130
+ chartConfig . zoom = {
131
+ enabled : true
140
132
}
141
133
c3 . generate ( chartConfig )
142
134
}
0 commit comments