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
2 changes: 1 addition & 1 deletion src/services/MCPService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ export class MCPService {
"tasknotes_get_time_summary",
"Get time tracking summary for a period",
{
period: z.enum(["today", "week", "month", "all"]).optional().describe("Time period (default: today)"),
period: z.enum(["today", "week", "month", "all", "custom"]).optional().describe("Time period (default: today)"),
from: z.string().optional().describe("Start date (ISO string) for custom range"),
to: z.string().optional().describe("End date (ISO string) for custom range"),
},
Expand Down
34 changes: 34 additions & 0 deletions tests/unit/utils/timeTrackingUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,40 @@ describe('timeTrackingUtils', () => {
expect(result.topTags).toBeUndefined();
});

it('should filter by custom date range when period is "custom"', () => {
const tasks: TaskInfo[] = [
TaskFactory.createTask({
title: 'In Range',
path: '/tasks/in-range.md',
timeEntries: [
{ startTime: '2025-03-03T10:00:00Z', endTime: '2025-03-03T10:30:00Z', duration: 30 },
],
}),
TaskFactory.createTask({
title: 'Out of Range',
path: '/tasks/out-of-range.md',
timeEntries: [
{ startTime: '2025-01-01T10:00:00Z', endTime: '2025-01-01T10:30:00Z', duration: 30 },
],
}),
];

const result = computeTimeSummary(
tasks,
{
period: 'custom',
fromDate: new Date('2025-03-01T00:00:00Z'),
toDate: new Date('2025-03-04T23:59:59Z'),
},
isCompleted
);

expect(result.summary.totalMinutes).toBe(30);
expect(result.summary.tasksWithTime).toBe(1);
expect(result.topTasks).toHaveLength(1);
expect(result.topTasks[0].title).toBe('In Range');
});

it('should sort top tasks by minutes descending', () => {
const tasks: TaskInfo[] = [
TaskFactory.createTask({
Expand Down