5
5
<!-- API Error Message -->
6
6
<div v-if =" apiError" class =" error-message" v-html =" apiError" ></div >
7
7
<div v-if =" !apiError" >
8
+ <div class =" tiles-container" >
9
+ <!-- Acceptance Rate Tile -->
10
+ <div class =" tile" >
11
+ <h3 >Acceptance Rate Average</h3 >
12
+ <p >{{ acceptanceRateAverage.toFixed(2) }}%</p >
13
+ <p >Over the last 28 days</p >
14
+ </div >
15
+
16
+ <div class =" tile" >
17
+ <h3 >Cumulative Number of Suggestions</h3 >
18
+ <p >{{ cumulativeNumberSuggestions }}</p >
19
+ <p >On the last 28 days</p >
20
+ </div >
21
+
22
+ <div class =" tile" >
23
+ <h3 >Cumulative Number of Accepted Prompts</h3 >
24
+ <p >{{ cumulativeNumberAcceptances }}</p >
25
+ <p >On the last 28 days</p >
26
+ </div >
27
+
28
+ <div class =" tile" >
29
+ <h3 >Cumulative Number of Lines of Code Accepted</h3 >
30
+ <p >{{ cumulativeNumberLOCAccepted }}</p >
31
+ <p >On the last 28 days</p >
32
+ </div >
33
+ </div >
34
+
35
+
8
36
<h2 >Acceptance rate (%)</h2 >
9
37
<Bar :data =" acceptanceRateChartData" :options =" chartOptions" />
10
38
@@ -81,6 +109,12 @@ export default defineComponent({
81
109
setup() {
82
110
const metrics = ref <Metrics []>([]);
83
111
112
+ // Tiles
113
+ let acceptanceRateAverage = ref (0 );
114
+ let cumulativeNumberSuggestions = ref (0 );
115
+ let cumulativeNumberAcceptances = ref (0 );
116
+ let cumulativeNumberLOCAccepted = ref (0 );
117
+
84
118
// Acceptance Rate
85
119
const acceptanceRateChartData = ref <{ labels: string []; datasets: any [] }>({ labels: [], datasets: [] });
86
120
@@ -136,26 +170,45 @@ export default defineComponent({
136
170
getGitHubCopilotMetricsApi ().then (data => {
137
171
metrics .value = data ;
138
172
173
+ cumulativeNumberSuggestions .value = 0 ;
174
+ const cumulativeSuggestionsData = data .map (m => {
175
+ cumulativeNumberSuggestions .value += m .total_suggestions_count ;
176
+ return m .total_suggestions_count ;
177
+ });
178
+
179
+ cumulativeNumberAcceptances .value = 0 ;
180
+ const cumulativeAcceptancesData = data .map (m => {
181
+ cumulativeNumberAcceptances .value += m .total_acceptances_count ;
182
+ return m .total_acceptances_count ;
183
+ });
184
+
139
185
totalSuggestionsAndAcceptanceChartData .value = {
140
186
labels: data .map (m => m .day ),
141
187
datasets: [
142
188
{
143
189
label: ' Total Suggestions' ,
144
- data: data . map ( m => m . total_suggestions_count ) ,
190
+ data: cumulativeSuggestionsData ,
145
191
backgroundColor: ' rgba(75, 192, 192, 0.2)' ,
146
192
borderColor: ' rgba(75, 192, 192, 1)'
147
193
148
194
},
149
195
{
150
196
label: ' Total Acceptance' ,
151
- data: data . map ( m => m . total_acceptances_count ) ,
197
+ data: cumulativeAcceptancesData ,
152
198
backgroundColor: ' rgba(153, 102, 255, 0.2)' ,
153
199
borderColor: ' rgba(153, 102, 255, 1)'
154
200
},
155
201
156
202
]
157
203
};
158
204
205
+ cumulativeNumberLOCAccepted .value = 0 ;
206
+ const cumulativeLOCAcceptedData = data .map (m => {
207
+ const total_lines_accepted = m .total_lines_accepted ;
208
+ cumulativeNumberLOCAccepted .value += total_lines_accepted ;
209
+ return total_lines_accepted ;
210
+ });
211
+
159
212
chartData .value = {
160
213
labels: data .map (m => m .day ),
161
214
datasets: [
@@ -168,21 +221,28 @@ export default defineComponent({
168
221
},
169
222
{
170
223
label: ' Total Lines Accepted' ,
171
- data: data . map ( m => m . total_lines_accepted ) ,
224
+ data: cumulativeLOCAcceptedData ,
172
225
backgroundColor: ' rgba(153, 102, 255, 0.2)' ,
173
226
borderColor: ' rgba(153, 102, 255, 1)'
174
227
}
175
228
]
176
229
};
177
230
231
+ let sum = 0 ;
232
+ const acceptanceRates = data .map (m => {
233
+ const rate = m .total_lines_suggested !== 0 ? (m .total_lines_accepted / m .total_lines_suggested ) * 100 : 0 ;
234
+ sum += rate ;
235
+ return rate ;
236
+ });
237
+ acceptanceRateAverage .value = sum / data .length ;
238
+
178
239
acceptanceRateChartData .value = {
179
- labels: data
180
- .map (m => m .day ),
240
+ labels: data .map (m => m .day ),
181
241
datasets: [
182
242
{
183
243
type: ' line' , // This makes the dataset a line in the chart
184
244
label: ' Acceptance Rate' ,
185
- data: data . map ( m => m . total_lines_suggested !== 0 ? ( m . total_lines_accepted / m . total_lines_suggested ) * 100 : 0 ) ,
245
+ data: acceptanceRates ,
186
246
backgroundColor: ' rgba(173, 216, 230, 0.2)' , // light blue
187
247
borderColor: ' rgba(173, 216, 230, 1)' , // darker blue
188
248
fill: false // This makes the area under the line not filled
@@ -260,8 +320,8 @@ export default defineComponent({
260
320
261
321
return { totalSuggestionsAndAcceptanceChartData , chartData ,
262
322
chartOptions , totalActiveUsersChartData ,
263
- totalActiveUsersChartOptions , acceptanceRateChartData , apiError ,
264
- languages };
323
+ totalActiveUsersChartOptions , acceptanceRateChartData , apiError , acceptanceRateAverage , cumulativeNumberSuggestions ,
324
+ cumulativeNumberAcceptances , cumulativeNumberLOCAccepted , languages };
265
325
},
266
326
267
327
@@ -277,4 +337,20 @@ export default defineComponent({
277
337
margin-left : auto ;
278
338
margin-right : auto ;
279
339
}
340
+
341
+ .tiles-container {
342
+ display : flex ;
343
+ justify-content : flex-start ;
344
+ flex-wrap : wrap ;
345
+ }
346
+
347
+ .tile {
348
+ border : 1px solid #ccc ;
349
+ box-shadow : 3px 3px 5px rgba (0 , 0 , 0 , 0.1 ),
350
+ -3px -3px 5px rgba (255 , 255 , 255 , 0.7 );
351
+ padding : 20px ;
352
+ border-radius : 10px ;
353
+ width : 20% ;
354
+ margin : 1% ;
355
+ }
280
356
</style >
0 commit comments