Skip to content

Commit 2eb93b0

Browse files
twentyTwo4Source
andauthored
Feature/pr 85 (#99)
* Fix Daily average when less than 30 days * Extend functionality of generated debug by input box to enter the number of days which should be generated * Fix Time Summary Skipped labels + not using foreground color * fix: bump version to 0.7.6 in package.json --------- Co-authored-by: 4Source <38220764+4Source@users.noreply.github.com>
1 parent 22fe4ac commit 2eb93b0

3 files changed

Lines changed: 32 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "simple-coding-time-tracker",
33
"displayName": "Simple Coding Time Tracker",
44
"description": "Automatic time tracking for VS Code — Track coding time per project, branch & language with smart activity detection, health reminders, and beautiful visualizations",
5-
"version": "0.7.5",
5+
"version": "0.7.6",
66
"publisher": "noorashuvo",
77
"license": "MIT",
88
"icon": "icon-sctt.png",

src/extension.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,39 @@ export function activate(context: vscode.ExtensionContext) {
167167
'php', 'ruby', 'swift', 'kotlin', 'html', 'css', 'scss', 'json', 'yaml', 'markdown', 'sql', 'bash'
168168
];
169169

170+
const value = await vscode.window.showInputBox({
171+
title: 'Enter the number of days which should be generated',
172+
prompt: 'Please enter the number of days',
173+
placeHolder: '90 to generate entries for the last 90 days',
174+
validateInput: (input) => {
175+
if(isNaN(Number(input))) {
176+
return 'Must be a number';
177+
}
178+
// Only Positive integers without 0
179+
if(!(/^[1-9][[0-9]*$/.test(input))) {
180+
return 'Enter an integer greater than 0';
181+
}
182+
return null
183+
}
184+
})
185+
186+
if (value == undefined) {
187+
// user cancelled the input
188+
return;
189+
}
190+
170191
const today = new Date();
171192
let totalEntries = 0;
193+
const days = Number(value);
172194

173195
await vscode.window.withProgress({
174196
location: vscode.ProgressLocation.Notification,
175197
title: "🎲 Generating test data...",
176198
cancellable: false
177199
}, async (progress) => {
178200
try {
179-
// Generate data for the last 90 days
180-
for (let i = 0; i < 90; i++) {
201+
// Generate data for the last x days
202+
for (let i = 0; i < days; i++) {
181203
const date = new Date(today);
182204
date.setDate(date.getDate() - i);
183205

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

202224
// Update progress
203-
progress.report({ increment: (1/90) * 100 });
225+
progress.report({ increment: (1/days) * 100 });
204226
}
205227

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

221-
vscode.window.showInformationMessage(`✅ Generated ${totalEntries} test entries successfully!`);
243+
vscode.window.showInformationMessage(`✅ Generated ${totalEntries} test entries for ${days} days successfully!`);
222244
});
223245

224246
// Delete test data command

src/summaryView.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,10 +1312,11 @@ export class SummaryViewProvider implements vscode.WebviewViewProvider {
13121312
y: {
13131313
display: true,
13141314
ticks: {
1315+
autoSkip: false,
13151316
font: {
13161317
size: 9
13171318
},
1318-
color: 'var(--vscode-foreground)',
1319+
color: getComputedStyle(document.documentElement).getPropertyValue('--vscode-foreground') || '#000',
13191320
padding: 5
13201321
},
13211322
grid: {
@@ -1738,7 +1739,9 @@ export class SummaryViewProvider implements vscode.WebviewViewProvider {
17381739
17391740
function updateDailyAverageAnalytics(data, allEntries) {
17401741
const last30Days = getLast30DaysData(allEntries);
1741-
const avgTime = last30Days.reduce((sum, day) => sum + day.time, 0) / 30;
1742+
let firstActiveDay = last30Days.findIndex((value, index, obj) => value.time > 0);
1743+
const numberOfDays = Math.min(30, 30 - firstActiveDay);
1744+
const avgTime = last30Days.reduce((sum, day) => sum + day.time, 0) / numberOfDays;
17421745
17431746
document.getElementById('daily-average').textContent = formatTime(avgTime);
17441747

0 commit comments

Comments
 (0)