Skip to content

Commit aaecca3

Browse files
committed
fix: address third review round
- toggl_search_time_entries: when `period` is given alongside only one of start_date/end_date, fill the missing boundary from the period instead of silently ignoring the period and failing validation a few lines later (Copilot). - utils.createReportEntry: drop a stray double blank line left over from the effectiveDurationSeconds extraction (Copilot).
1 parent eddac85 commit aaecca3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,14 +532,15 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
532532
}
533533
await ensureCache();
534534

535-
// Explicit start/end wins; otherwise derive from `period`. Reports
536-
// API requires a date range, so we reject if neither is provided.
535+
// Explicit start/end wins, but when `period` is supplied we use it
536+
// to fill in whichever boundary is missing. Reports API requires a
537+
// full date range, so we reject if we still cannot determine both.
537538
let startDate: string | undefined = args?.start_date as string | undefined;
538539
let endDate: string | undefined = args?.end_date as string | undefined;
539-
if (!startDate && !endDate && args?.period) {
540+
if (args?.period && (!startDate || !endDate)) {
540541
const range = getDateRange(args.period as any);
541-
startDate = range.start.toISOString().split('T')[0];
542-
endDate = range.end.toISOString().split('T')[0];
542+
startDate = startDate ?? range.start.toISOString().split('T')[0];
543+
endDate = endDate ?? range.end.toISOString().split('T')[0];
543544
}
544545
if (!startDate || !endDate) {
545546
throw new Error('Reports API requires both start_date and end_date (or a period).');

src/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ export function calculateTotalDuration(entries: HydratedTimeEntry[]): number {
157157
export function createReportEntry(entry: HydratedTimeEntry): ReportEntry {
158158
const duration = effectiveDurationSeconds(entry);
159159

160-
161160
return {
162161
id: entry.id,
163162
workspace: entry.workspace_name,

0 commit comments

Comments
 (0)