Skip to content

Commit

Permalink
feat: Add XY chart generation for acceptance rates and daily active u…
Browse files Browse the repository at this point in the history
…sers in job summary
  • Loading branch information
austenstone committed Feb 21, 2025
1 parent cda0dc9 commit 484d1f5
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 12 deletions.
58 changes: 55 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131952,6 +131952,56 @@ title Editor Usage
.join('\n')}
\`\`\`\n`;
};
const job_summary_generateXyChart = (data, title, yAxisTitle, dataForBar, dataForLine, maxData) => {
return `\n\`\`\`mermaid
---
config:
xyChart:
width: ${data.length * 45}
height: 500
xAxis:
labelPadding: 20
themeVariables:
xyChart:
backgroundColor: "transparent"
---
xychart-beta
title "${title}"
x-axis [${data.map((day) => `"${job_summary_dateFormat(day.date, { month: '2-digit', day: '2-digit' })}"`).join(', ')}]
y-axis "${yAxisTitle}" 0 --> ${maxData}
bar [${data.map(dataForBar).map(v => isFinite(v) ? v.toFixed(3) : '0.000').join(', ')}]
line [${data.map(dataForLine).map(v => isFinite(v) ? v.toFixed(3) : '0.000').join(', ')}]
\`\`\`\n`;
};
const job_summary_getXyChartAcceptanceRate = (data) => {
const maxAcceptances = Math.max(...data.map((day) => day.copilot_ide_code_completions?.editors?.reduce((sum, editor) => sum + (editor.models?.reduce((mSum, model) => mSum + (model.languages?.reduce((lSum, lang) => lSum + (lang.total_code_acceptances || 0), 0) || 0), 0) || 0), 0) || 0)) + 10;
return job_summary_generateXyChart(data, "Completion Accepts & Acceptance Rate", "Acceptances", (day) => day.copilot_ide_code_completions?.editors?.reduce((sum, editor) => sum + (editor.models?.reduce((mSum, model) => mSum + (model.languages?.reduce((lSum, lang) => lSum + (lang.total_code_acceptances || 0), 0) || 0), 0) || 0), 0) || 0, (day) => {
const accepts = day.copilot_ide_code_completions?.editors?.reduce((sum, editor) => sum + (editor.models?.reduce((mSum, model) => mSum + (model.languages?.reduce((lSum, lang) => lSum + (lang.total_code_acceptances || 0), 0) || 0), 0) || 0), 0) || 0;
const suggestions = day.copilot_ide_code_completions?.editors?.reduce((sum, editor) => sum + (editor.models?.reduce((mSum, model) => mSum + (model.languages?.reduce((lSum, lang) => lSum + (lang.total_code_suggestions || 0), 0) || 0), 0) || 0), 0) || 0;
return ((accepts / suggestions) * maxAcceptances) || 0;
}, maxAcceptances);
};
const job_summary_getXyChartDailyActiveUsers = (data) => {
const maxActiveUsers = Math.max(...data.map((day) => getTotalEngagedUsers(day))) + 10;
return `\n\`\`\`mermaid
---
config:
xyChart:
width: ${data.length * 45}
height: 500
xAxis:
labelPadding: 20
themeVariables:
xyChart:
backgroundColor: "transparent"
---
xychart-beta
title "Daily Active Users"
x-axis [${data.map((day) => `"${job_summary_dateFormat(day.date, { month: '2-digit', day: '2-digit' })}"`).join(', ')}]
y-axis "Active Users" 0 --> ${maxActiveUsers}
line [${data.map((day) => getTotalEngagedUsers(day)).join(', ')}]
\`\`\`\n`;
};
const job_summary_createJobSummaryUsage = (data, name) => {
const languageMetrics = groupLanguageMetrics(data);
const editorMetrics = groupEditorMetrics(data);
Expand All @@ -131974,10 +132024,12 @@ const job_summary_createJobSummaryUsage = (data, name) => {
`Total Chat Interactions: ${totalChatTurns.toLocaleString()}`,
`Most Active Day: ${job_summary_dateFormat(mostActiveDay.date)} (${getTotalEngagedUsers(mostActiveDay)} active users)`
])
.addRaw(job_summary_getPieChartLanguageUsage(languageMetrics))
.addRaw(job_summary_getXyChartAcceptanceRate(data))
.addRaw(job_summary_getXyChartDailyActiveUsers(data))
.addHeading('Language Usage')
.addRaw(job_summary_getPieChartEditorUsage(editorMetrics))
.addHeading('Editor Usage');
.addRaw(job_summary_getPieChartLanguageUsage(languageMetrics))
.addHeading('Editor Usage')
.addRaw(job_summary_getPieChartEditorUsage(editorMetrics));
};
const getTotalEngagedUsers = (day) => {
return day.copilot_ide_code_completions?.editors?.reduce((sum, editor) => sum + (editor.total_engaged_users ?? 0), 0) || 0;
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

58 changes: 55 additions & 3 deletions dist/job-summary.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 484d1f5

Please sign in to comment.