1
1
<template >
2
- <div >
3
- </div >
2
+ <!-- API Error Message -->
3
+ <div v-if =" apiError" class =" error-message" v-html =" apiError" ></div >
4
+ <div v-if =" !apiError" >
5
+ <div class =" tiles-container" >
6
+ <v-card elevation =" 4" color =" white" variant =" elevated" class =" mx-auto my-3" style =" width : 300px ; height : 175px ;" >
7
+ <v-card-item >
8
+ <div >
9
+ <div class =" text-overline mb-1" style =" visibility : hidden ;" >filler</div >
10
+ <div class =" text-h6 mb-1" >Cumulative Number of Turns</div >
11
+ <div class =" text-caption" >
12
+ Over the last 28 days
13
+ </div >
14
+ <p >{{ cumulativeNumberTurns }}</p >
15
+ </div >
16
+ </v-card-item >
17
+ </v-card >
18
+
19
+ <v-card elevation =" 4" color =" white" variant =" elevated" class =" mx-auto my-3" style =" width : 300px ; height : 175px ;" >
20
+ <v-card-item >
21
+ <div >
22
+ <div class =" text-overline mb-1" style =" visibility : hidden ;" >filler</div >
23
+ <div class =" text-h6 mb-1" >Cumulative Number of Lines of Code Accepted</div >
24
+ <div class =" text-caption" >
25
+ Over the last 28 days
26
+ </div >
27
+ <p >{{ cumulativeNumberAcceptances }}</p >
28
+ </div >
29
+ </v-card-item >
30
+ </v-card >
31
+ </div >
32
+ <v-main class =" p-1" style =" min-height : 300px ;" >
33
+
34
+ <v-container style =" min-height : 300px ;" class =" px-4 elevation-2" >
35
+
36
+ <h2 >Total Suggestions Count | Total Acceptances Count</h2 >
37
+ <Line :data =" totalNumberAcceptancesAndTurnsChartData" :options =" chartOptions" />
38
+
39
+ <h2 >Total Active Copilot Chat Users</h2 >
40
+ <Bar :data =" totalActiveCopilotChatUsersChartData" :options =" totalActiveChatUsersChartOptions" />
41
+
42
+ </v-container >
43
+ </v-main >
44
+
45
+ </div >
46
+
4
47
</template >
5
48
6
49
<script lang="ts">
7
50
import { defineComponent , ref } from ' vue' ;
8
51
import { getGitHubCopilotMetricsApi } from ' ../api/GitHubApi' ;
9
52
import { Metrics } from ' ../model/MetricsData' ;
53
+ import {
54
+ Chart as ChartJS ,
55
+ ArcElement ,
56
+ CategoryScale ,
57
+ LinearScale ,
58
+ PointElement ,
59
+ LineElement ,
60
+ BarElement ,
61
+ Title ,
62
+ Tooltip ,
63
+ Legend
64
+ } from ' chart.js'
65
+
66
+ import { Line } from ' vue-chartjs'
67
+ import { Bar } from ' vue-chartjs'
68
+
69
+ ChartJS .register (
70
+ ArcElement ,
71
+ CategoryScale ,
72
+ LinearScale ,
73
+ BarElement ,
74
+ PointElement ,
75
+ LineElement ,
76
+ Title ,
77
+ Tooltip ,
78
+ Legend
79
+ )
80
+
81
+
10
82
11
83
12
84
export default defineComponent ({
13
85
name: ' CopilotChatViewer' ,
86
+ components: {
87
+ Bar ,
88
+ Line
89
+ },
14
90
setup() {
15
91
const metrics = ref <Metrics []>([]);
16
92
17
93
const apiError = ref <string >(' ' );
18
94
95
+ let cumulativeNumberAcceptances = ref (0 );
96
+
97
+ let cumulativeNumberTurns = ref (0 );
98
+
99
+ // Total Copilot Chat Active Users
100
+ const totalActiveCopilotChatUsersChartData = ref <{ labels: string []; datasets: any [] }>({ labels: [], datasets: [] });
101
+
102
+ const totalActiveChatUsersChartOptions = {
103
+ responsive: true ,
104
+ maintainAspectRatio: true ,
105
+ scales: {
106
+ y: {
107
+ beginAtZero: true ,
108
+ ticks: {
109
+ stepSize: 1
110
+ }
111
+ }
112
+ },
113
+ layout: {
114
+ padding: {
115
+ left: 50 ,
116
+ right: 50 ,
117
+ top: 50 ,
118
+ bottom: 50
119
+ }
120
+ },
121
+ };
122
+
123
+ const chartOptions = {
124
+ responsive: true ,
125
+ maintainAspectRatio: true ,
126
+ height: 300 ,
127
+ width: 300 ,
128
+ layout: {
129
+ padding: {
130
+ left: 150 ,
131
+ right: 150 ,
132
+ top: 20 ,
133
+ bottom: 40
134
+ }
135
+ },
136
+ };
137
+
138
+ // Total Number Acceptances And Turns
139
+ const totalNumberAcceptancesAndTurnsChartData = ref <{ labels: string []; datasets: any [] }>({ labels: [], datasets: [] });
140
+
19
141
getGitHubCopilotMetricsApi ().then (data => {
20
- metrics .value = data ;
142
+ metrics .value = data ;
143
+
144
+ console .log (' Metrics Data: ' + JSON .stringify (data ));
145
+
146
+ cumulativeNumberTurns .value = 0 ;
147
+ const cumulativeNumberTurnsData = data .map (m => {
148
+ cumulativeNumberTurns .value += m .total_chat_turns ;
149
+ return m .total_chat_turns ;
150
+ });
151
+
152
+ cumulativeNumberAcceptances .value = 0 ;
153
+ const cumulativeNumberAcceptancesData = data .map (m => {
154
+ cumulativeNumberAcceptances .value += m .total_chat_acceptances ;
155
+ return m .total_chat_acceptances ;
156
+ });
157
+
158
+ totalNumberAcceptancesAndTurnsChartData .value = {
159
+ labels: data .map (m => m .day ),
160
+ datasets: [
161
+ {
162
+ label: ' Total Acceptances' ,
163
+ data: cumulativeNumberAcceptancesData ,
164
+ backgroundColor: ' rgba(75, 192, 192, 0.2)' ,
165
+ borderColor: ' rgba(75, 192, 192, 1)'
166
+
167
+ },
168
+ {
169
+ label: ' Total Turns' ,
170
+ data: cumulativeNumberTurnsData ,
171
+ backgroundColor: ' rgba(153, 102, 255, 0.2)' ,
172
+ borderColor: ' rgba(153, 102, 255, 1)'
173
+ }
174
+
175
+ ]
176
+ };
177
+
178
+ totalActiveCopilotChatUsersChartData .value = {
179
+ labels: data .map (m => m .day ),
180
+ datasets: [
181
+ {
182
+ label: ' Total Active Copilot Chat Users' ,
183
+ data: data .map (m => m .total_active_chat_users ),
184
+ backgroundColor: ' rgba(0, 0, 139, 0.2)' , // dark blue with 20% opacity
185
+ borderColor: ' rgba(255, 99, 132, 1)'
186
+ }
187
+ ]
188
+ };
189
+
21
190
}).catch (error => {
22
191
console .log (error );
23
192
// Check the status code of the error response
42
211
43
212
});
44
213
45
- return { apiError , metrics };
214
+ return { apiError , metrics , totalActiveCopilotChatUsersChartData , totalActiveChatUsersChartOptions , cumulativeNumberAcceptances , cumulativeNumberTurns , totalNumberAcceptancesAndTurnsChartData , chartOptions };
46
215
}
47
216
});
48
217
</script >
49
218
50
219
<style scoped>
51
-
220
+ .tiles-container {
221
+ display : flex ;
222
+ justify-content : flex-start ;
223
+ flex-wrap : wrap ;
224
+ }
52
225
</style >
0 commit comments