Skip to content

Commit

Permalink
Issue #81 - On starting a timer mark TP task as "In Progress", if cur…
Browse files Browse the repository at this point in the history
…rent task state is "Open" or "Dev ready" (#82)

* start TP task on start

* fix linting issues

* removed comments as added to wiki

* removed issue related comments as Git issues are linked
  • Loading branch information
tarunvd authored Feb 26, 2021
1 parent 0f859b2 commit 6b50076
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/commands/finish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
15 changes: 15 additions & 0 deletions src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,25 @@ 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);

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);
}
Expand Down

0 comments on commit 6b50076

Please sign in to comment.