Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,39 @@ export function activate(context: vscode.ExtensionContext) {
'php', 'ruby', 'swift', 'kotlin', 'html', 'css', 'scss', 'json', 'yaml', 'markdown', 'sql', 'bash'
];

const value = await vscode.window.showInputBox({
title: 'Enter the number of days which should be generated',
prompt: 'Please enter the number of days',
placeHolder: '90 to generate entries for the last 90 days',
validateInput: (input) => {
if(isNaN(Number(input))) {
return 'Must be a number';
}
// Only Positive integers without 0
if(!(/^[1-9][[0-9]*$/.test(input))) {
return 'Enter an integer greater than 0';
}
return null
}
})

if (value == undefined) {
// user cancelled the input
return;
}

const today = new Date();
let totalEntries = 0;
const days = Number(value);

await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
title: "🎲 Generating test data...",
cancellable: false
}, async (progress) => {
try {
// Generate data for the last 90 days
for (let i = 0; i < 90; i++) {
// Generate data for the last x days
for (let i = 0; i < days; i++) {
const date = new Date(today);
date.setDate(date.getDate() - i);

Expand All @@ -200,7 +222,7 @@ export function activate(context: vscode.ExtensionContext) {
}

// Update progress
progress.report({ increment: (1/90) * 100 });
progress.report({ increment: (1/days) * 100 });
}

// Add some special test cases for yesterday and today
Expand All @@ -218,7 +240,7 @@ export function activate(context: vscode.ExtensionContext) {
}
});

vscode.window.showInformationMessage(`✅ Generated ${totalEntries} test entries successfully!`);
vscode.window.showInformationMessage(`✅ Generated ${totalEntries} test entries for ${days} days successfully!`);
});

// Delete test data command
Expand Down
7 changes: 5 additions & 2 deletions src/summaryView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1312,10 +1312,11 @@ export class SummaryViewProvider implements vscode.WebviewViewProvider {
y: {
display: true,
ticks: {
autoSkip: false,
font: {
size: 9
},
color: 'var(--vscode-foreground)',
color: getComputedStyle(document.documentElement).getPropertyValue('--vscode-foreground') || '#000',
padding: 5
},
grid: {
Expand Down Expand Up @@ -1738,7 +1739,9 @@ export class SummaryViewProvider implements vscode.WebviewViewProvider {

function updateDailyAverageAnalytics(data, allEntries) {
const last30Days = getLast30DaysData(allEntries);
const avgTime = last30Days.reduce((sum, day) => sum + day.time, 0) / 30;
let firstActiveDay = last30Days.findIndex((value, index, obj) => value.time > 0);
const numberOfDays = Math.min(30, 30 - firstActiveDay);
const avgTime = last30Days.reduce((sum, day) => sum + day.time, 0) / numberOfDays;

document.getElementById('daily-average').textContent = formatTime(avgTime);

Expand Down