From 01beb91d93113b397cf3fbdfe3091c07bf3401a5 Mon Sep 17 00:00:00 2001 From: Tarun Dalwani Date: Wed, 10 Feb 2021 22:16:04 +0530 Subject: [PATCH 1/4] start TP task on start --- src/commands/start.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/commands/start.ts b/src/commands/start.ts index b95aff9..94d851c 100644 --- a/src/commands/start.ts +++ b/src/commands/start.ts @@ -16,10 +16,29 @@ export const start = async (packageVersion: string, apiProvider: ApiProvider, da const notes = createNotes(noteInformation, [ details.notes ]); const harvestApi = apiProvider.getHarvestApi(); + const targetprocessApi = apiProvider.getTargetprocessApi(); log.info("Starting Harvest timer..."); try { await harvestApi.startTimeEntry(details.projectId, details.taskId, date, notes, details.hours, details.running); + + // Issue #81: If the linked TP entity is a Task *and* its current state is 'Open' or 'Dev ready', set the task to 'In Progress' + // Note: It is important to verify current state of Task, otherwise if a 'Done' task with time remaining is moved to 'In Progress', + // it may increase the time on a story / feature which the dev / user might not realize as the task has moved to 'In Progress' by this utility + // And if the time remaining has not reached 0, the task might not move to 'Done' when the timer is finished + if (details.entity && + details.entity.Id && + details.entity.ResourceType === "Task" && + details.entity.EntityState && + details.entity.EntityState.Name && + (details.entity.EntityState.Name.toUpperCase() === "OPEN" || + details.entity.EntityState.Name.toUpperCase() === "DEV READY") && + details.entity.Project && + details.entity.Project.Process && + details.entity.Project.Process.Id) { + + await targetprocessApi.setTaskState(details.entity.Id, "In Progress", details.entity.Project.Process.Id); + } } catch (e) { log.error(e); } From 3c28f31754ff8d184a5d9fb3f121e8c83c0fe158 Mon Sep 17 00:00:00 2001 From: Tarun Dalwani Date: Wed, 10 Feb 2021 22:26:30 +0530 Subject: [PATCH 2/4] fix linting issues --- src/commands/start.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/start.ts b/src/commands/start.ts index 94d851c..e528d49 100644 --- a/src/commands/start.ts +++ b/src/commands/start.ts @@ -21,11 +21,11 @@ export const start = async (packageVersion: string, apiProvider: ApiProvider, da log.info("Starting Harvest timer..."); try { await harvestApi.startTimeEntry(details.projectId, details.taskId, date, notes, details.hours, details.running); - + // Issue #81: If the linked TP entity is a Task *and* its current state is 'Open' or 'Dev ready', set the task to 'In Progress' // Note: It is important to verify current state of Task, otherwise if a 'Done' task with time remaining is moved to 'In Progress', // it may increase the time on a story / feature which the dev / user might not realize as the task has moved to 'In Progress' by this utility - // And if the time remaining has not reached 0, the task might not move to 'Done' when the timer is finished + // And if the time remaining has not reached 0, the task might not move to 'Done' when the timer is finished if (details.entity && details.entity.Id && details.entity.ResourceType === "Task" && From bc48517baa5b99b8a39279049464c9c5ac0a8093 Mon Sep 17 00:00:00 2001 From: Tarun Dalwani Date: Fri, 12 Feb 2021 14:09:53 +0530 Subject: [PATCH 3/4] removed comments as added to wiki --- src/commands/start.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/commands/start.ts b/src/commands/start.ts index e528d49..c68f335 100644 --- a/src/commands/start.ts +++ b/src/commands/start.ts @@ -23,9 +23,6 @@ export const start = async (packageVersion: string, apiProvider: ApiProvider, da await harvestApi.startTimeEntry(details.projectId, details.taskId, date, notes, details.hours, details.running); // Issue #81: If the linked TP entity is a Task *and* its current state is 'Open' or 'Dev ready', set the task to 'In Progress' - // Note: It is important to verify current state of Task, otherwise if a 'Done' task with time remaining is moved to 'In Progress', - // it may increase the time on a story / feature which the dev / user might not realize as the task has moved to 'In Progress' by this utility - // And if the time remaining has not reached 0, the task might not move to 'Done' when the timer is finished if (details.entity && details.entity.Id && details.entity.ResourceType === "Task" && From 4e84ecb9f460938b0a34638d686e0ae497777a43 Mon Sep 17 00:00:00 2001 From: Tarun Dalwani Date: Fri, 26 Feb 2021 14:38:37 +0530 Subject: [PATCH 4/4] removed issue related comments as Git issues are linked --- src/commands/finish.ts | 1 - src/commands/start.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/commands/finish.ts b/src/commands/finish.ts index c7d8dd0..c64c1dc 100644 --- a/src/commands/finish.ts +++ b/src/commands/finish.ts @@ -75,7 +75,6 @@ const updateTargetprocess = async (targetprocessApi: Targetprocess, request: Fin const notes = getTargetprocessNotes(request, timeEntity); - // Issue #64: If the linked TP entity is a Task *and* its timeRemaining is 0, set the task to 'Done' if (timeEntity.ResourceType === "Task" && request.timeRemaining === 0 && request.tpEntity && diff --git a/src/commands/start.ts b/src/commands/start.ts index c68f335..f911b10 100644 --- a/src/commands/start.ts +++ b/src/commands/start.ts @@ -22,7 +22,6 @@ export const start = async (packageVersion: string, apiProvider: ApiProvider, da try { await harvestApi.startTimeEntry(details.projectId, details.taskId, date, notes, details.hours, details.running); - // Issue #81: If the linked TP entity is a Task *and* its current state is 'Open' or 'Dev ready', set the task to 'In Progress' if (details.entity && details.entity.Id && details.entity.ResourceType === "Task" &&