Skip to content

Commit 01abb20

Browse files
committed
feat: enhance daily activity chart with new metrics and acceptance rate; improve data handling in HighchartsService
1 parent ca4d469 commit 01abb20

3 files changed

Lines changed: 71 additions & 25 deletions

File tree

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
<highcharts-chart [Highcharts]="Highcharts" [options]="_chartOptions" (chartInstance)="onChartInstance($event)">
1+
<highcharts-chart
2+
[Highcharts]="Highcharts"
3+
[options]="_chartOptions"
4+
[update]="updateFlag"
5+
(chartInstance)="onChartInstance($event)">
26
</highcharts-chart>

frontend/src/app/main/copilot/copilot-value/daily-activity-chart/daily-activity-chart.component.ts

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,19 @@ export class DailyActivityChartComponent implements OnInit, OnChanges {
3535
'IDE Suggestions': this.targets?.user.dailySuggestions.target || 0,
3636
'IDE Accepts': this.targets?.user.dailyAcceptances.target || 0,
3737
'IDE Chats': this.targets?.user.dailyChatTurns.target || 0,
38-
'.COM Chats': this.targets?.user.dailyDotComChats.target || 0
38+
'.COM Chats': this.targets?.user.dailyDotComChats.target || 0,
39+
'IDE Acceptance Rate': 100 * ( this.targets?.user.dailyAcceptances.target || 0) / (this.targets?.user.dailySuggestions.target || 0), // NEW
40+
'Pull Requests': this.targets?.user.weeklyPRSummaries.target || 0 / 5 // 5 days in a week
3941
};
4042

4143
// NEW: mapping for typical ranges (from, to)
4244
const typicalRangeMapping: Record<string, [number, number]> = {
4345
'IDE Suggestions': [50, 90],
44-
'IDE Accepts': [20, 40],
46+
'IDE Accepts': [15, 40],
4547
'IDE Chats': [25, 40],
46-
'.COM Chats': [4, 8]
48+
'.COM Chats': [4, 8],
49+
'IDE Acceptance Rate': [20, 40], // NEW – percentage range (example)
50+
'Pull Requests': [1, 3] // NEW example range
4751
};
4852

4953
// the code below is to set the target line on the chart, based on the series name
@@ -136,19 +140,36 @@ export class DailyActivityChartComponent implements OnInit, OnChanges {
136140
fontSize: '14px'
137141
}
138142
},
139-
series: [{
140-
name: 'IDE Suggestions',
141-
type: 'spline',
142-
}, {
143-
name: 'IDE Accepts',
144-
type: 'spline',
145-
}, {
146-
name: 'IDE Chats',
147-
type: 'spline',
148-
}, {
149-
name: '.COM Chats',
150-
type: 'spline',
151-
}]
143+
series: [
144+
{ name: 'IDE Suggestions', type: 'spline', data: [], zIndex: 5 },
145+
{ name: 'IDE Accepts', type: 'spline', data: [], zIndex: 4 },
146+
{ name: 'IDE Acceptance Rate', type: 'spline', data: [], zIndex: 3 },
147+
{ name: 'IDE Chats', type: 'spline', data: [], color: '#00E676', zIndex: 5 },
148+
{ name: '.COM Chats', type: 'spline', data: [], color: '#E91E63', zIndex: 4 },
149+
{ name: 'Pull Requests', type: 'spline', data: [], color: '#9C27B0', zIndex: 3 }
150+
],
151+
plotOptions: {
152+
series: {
153+
events: {
154+
legendItemClick: function () {
155+
const chart = this.chart as Highcharts.Chart & { _isolated?: Highcharts.Series };
156+
157+
// if this series is already isolated → restore all
158+
if (chart._isolated === this) {
159+
chart.series.forEach(s => s.setVisible(true, false));
160+
chart._isolated = undefined;
161+
} else {
162+
// isolate the clicked series
163+
chart.series.forEach(s => s.setVisible(s === this, false));
164+
chart._isolated = this;
165+
}
166+
167+
chart.redraw(false);
168+
return false; // prevent default toggle
169+
}
170+
}
171+
}
172+
}
152173
};
153174

154175
constructor(
@@ -167,7 +188,9 @@ export class DailyActivityChartComponent implements OnInit, OnChanges {
167188
...this._chartOptions,
168189
...this.highchartsService.transformMetricsToDailyActivityLine(this.activity, this.metrics)
169190
};
170-
this.updateFlag = true;
191+
console.log('chart opts', this._chartOptions.series); // DEBUG
192+
// toggle so <highcharts-chart> detects a change
193+
this.updateFlag = !this.updateFlag;
171194
}
172195
}
173196

frontend/src/app/services/highcharts.service.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,12 @@ export class HighchartsService {
565565
name: 'IDE Accepts',
566566
data: [] as CustomHighchartsPointOptions[]
567567
};
568+
// NEW: acceptance-rate (% of suggestions accepted)
569+
const dailyActiveIdeAcceptanceRateSeries = {
570+
...initialSeries,
571+
name: 'IDE Acceptance Rate',
572+
data: [] as CustomHighchartsPointOptions[]
573+
};
568574
const dailyActiveIdeChatSeries = {
569575
...initialSeries,
570576
name: 'IDE Chats',
@@ -577,26 +583,38 @@ export class HighchartsService {
577583
};
578584
const dailyActiveDotcomPrSeries = {
579585
...initialSeries,
580-
name: '.COM Pull Requests',
586+
name: 'Pull Requests',
581587
data: [] as CustomHighchartsPointOptions[]
582588
};
583589

584590
Object.entries(activity).forEach(([date, dateData]) => {
585-
// Skip if totalActive is undefined or 0
591+
// Skip if totalActive is undefined or 0 or there is a data quality issue making daily suggestions per average user > 250
586592
const currentMetrics = metrics.find(m => m.date.startsWith(date.slice(0, 10)));
587-
if (!currentMetrics || (currentMetrics.copilot_ide_code_completions?.total_engaged_users ?? 0) < 1) return;
593+
if (!currentMetrics || (currentMetrics.copilot_ide_code_completions?.total_engaged_users ?? 0) < 1 || ((currentMetrics.copilot_ide_code_completions?.total_code_suggestions ?? 0) / (currentMetrics.copilot_ide_code_completions?.total_engaged_users ?? 1)) > 250) return;
588594

589595
if (currentMetrics?.copilot_ide_code_completions) {
596+
// Suggestions per user
590597
(dailyActiveIdeCompletionsSeries.data).push({
591598
x: new Date(date).getTime(),
592599
y: (currentMetrics.copilot_ide_code_completions.total_code_suggestions / currentMetrics.copilot_ide_code_completions.total_engaged_users),
593600
raw: date
594601
});
595602

596-
if (dailyActiveIdeAcceptsSeries && dailyActiveIdeAcceptsSeries.data) {
597-
dailyActiveIdeAcceptsSeries.data.push({
603+
// Accepts per user
604+
(dailyActiveIdeAcceptsSeries.data).push({
605+
x: new Date(date).getTime(),
606+
y: (currentMetrics.copilot_ide_code_completions.total_code_acceptances /
607+
currentMetrics.copilot_ide_code_completions.total_engaged_users),
608+
raw: date
609+
});
610+
611+
// NEW: acceptance-rate (%)
612+
const sugg = currentMetrics.copilot_ide_code_completions.total_code_suggestions;
613+
const acc = currentMetrics.copilot_ide_code_completions.total_code_acceptances;
614+
if (sugg > 0) {
615+
(dailyActiveIdeAcceptanceRateSeries.data).push({
598616
x: new Date(date).getTime(),
599-
y: (currentMetrics.copilot_ide_code_completions.total_code_acceptances / currentMetrics.copilot_ide_code_completions.total_engaged_users),
617+
y: +(acc / sugg * 100).toFixed(2),
600618
raw: date
601619
});
602620
}
@@ -628,9 +646,10 @@ export class HighchartsService {
628646
series: [
629647
dailyActiveIdeCompletionsSeries,
630648
dailyActiveIdeAcceptsSeries,
649+
dailyActiveIdeAcceptanceRateSeries, // NEW series added to output
631650
dailyActiveIdeChatSeries,
632651
dailyActiveDotcomChatSeries,
633-
// dailyActiveDotcomPrSeries,
652+
dailyActiveDotcomPrSeries // ← was commented out
634653
]
635654
}
636655
}

0 commit comments

Comments
 (0)