Closed danstreeter closed 4 years ago
Hi, thanks for your feedback. I will check if there is the possibility to force starting time. π
No problem, i'm going to look also - and see how my colleagues are doing it (not with this plugin, but via their own home written Jira worklog updaters), but may not be able to look at this until late this afternoon/evening when we are 'offline' work mode.
Indeed - just found the same. Am testing a change now. =)
I can confirm (via Postman tests) that the API allows the following payload to create a worklog at the submitted 'started' time:
{
"issueKey": "TP-203",
"timeSpentSeconds": 120,
"comment": "Testing API Worklog Entry at specific time",
"started": "2020-09-30T10:30:00.031+0100"
}
What I will struggle with is getting that format from the language (as not a language I know.
If you can provide me a way to get that date format, I can add, test and submit a new PR to fix this issue,
Agh, however it will need to be calculated using the timeSpentSeconds...
So 'started' == (now_in_seconds - timeSpentSeconds)
If you want to change yourself to get to the same point as me here is a simple patch:
diff --git a/src/commands/issue-add-worklog.ts b/src/commands/issue-add-worklog.ts
index 8d2403c..0fe81ef 100644
--- a/src/commands/issue-add-worklog.ts
+++ b/src/commands/issue-add-worklog.ts
@@ -11,7 +11,8 @@ export default async function issueAddWorklog(issueKey: string, timeSpentSeconds
const response = await store.state.jira.addWorkLog({
issueKey,
timeSpentSeconds: Math.ceil(timeSpentSeconds / 60) * 60,
- comment
+ comment,
+ started: "2020-09-30T10:30:00.031+0100"
});
const action = await vscode.window.showInformationMessage(`Worklog added`, 'Open in browser');
if (action === 'Open in browser') {
diff --git a/src/services/http.model.ts b/src/services/http.model.ts
index dae3060..5586ed8 100644
--- a/src/services/http.model.ts
+++ b/src/services/http.model.ts
@@ -113,6 +113,7 @@ export interface IAddWorkLog {
issueKey: string;
timeSpentSeconds: number;
comment?: string;
+ started: string;
}
export interface IIssueType {
You deserve the resolution π₯ I will release the new version with this fix π
Agh, i was just about there! ;) Lets see what we both come up with!!! =)
Haha, yes - My final change worked and submits successfully... I'd be interested in your fix - knowing the language, as I had to include a new function to turn the Date(),toISOString() format into one that Jira accepts with the actual timezone format (+0100) instead of Zulu.
My final diff (ready for commit, but I wont as you probably have a better fix) is as follows:
diff --git a/src/commands/issue-add-worklog.ts b/src/commands/issue-add-worklog.ts
index 8d2403c..09e9a2b 100644
--- a/src/commands/issue-add-worklog.ts
+++ b/src/commands/issue-add-worklog.ts
@@ -3,15 +3,27 @@ import { logger, store } from '../services';
import { NO_WORKING_ISSUE } from '../shared/constants';
import openIssue from './open-issue';
+function dateToLocalISO(date: Date) {
+ const off = date.getTimezoneOffset()
+ const absoff = Math.abs(off)
+ return (new Date(date.getTime() - off*60*1000).toISOString().substr(0,23) +
+ (off > 0 ? '-' : '+') +
+ (absoff / 60).toFixed(0).padStart(2,'0') +
+ (absoff % 60).toString().padStart(2,'0'))
+}
+
export default async function issueAddWorklog(issueKey: string, timeSpentSeconds: number, comment: string): Promise<void> {
try {
if (issueKey !== NO_WORKING_ISSUE.key) {
if (store.canExecuteJiraAPI()) {
// call Jira API
+ const actualTimeSpentSeconds = Math.ceil(timeSpentSeconds / 60) * 60
+ const startedTime = new Date(Date.now() - (actualTimeSpentSeconds * 1000))
const response = await store.state.jira.addWorkLog({
issueKey,
- timeSpentSeconds: Math.ceil(timeSpentSeconds / 60) * 60,
- comment
+ timeSpentSeconds: actualTimeSpentSeconds,
+ comment,
+ started: dateToLocalISO(startedTime)
});
const action = await vscode.window.showInformationMessage(`Worklog added`, 'Open in browser');
if (action === 'Open in browser') {
diff --git a/src/services/http.model.ts b/src/services/http.model.ts
index dae3060..5586ed8 100644
--- a/src/services/http.model.ts
+++ b/src/services/http.model.ts
@@ -113,6 +113,7 @@ export interface IAddWorkLog {
issueKey: string;
timeSpentSeconds: number;
comment?: string;
+ started: string;
}
export interface IIssueType {
Yep, I thought the same approach. Unfortunately date time is a difficult stuff in Js.
Yeah, I thought that... but thought it may have just been me having no real clue on this level of JS.
"Many a stack overflow post was read in the fixing of this bug"
@gioboa - Hows the new release going? Did you need me to push the code I did above or were you going with what you had?
I will include the code in the develop branch and I will release the new version. π
Describe the issue When submitting a work log via either the 'Set Working Issue -> No Working Issue' or 'Stop Working On Issue' commands, the time logged in Jira STARTS at the submitted time, not 'Now - time worked' E.G.
To Reproduce Steps to reproduce the behavior:
Expected behavior The time logged should start at the time of the worklog tracking start time, not the submission time. E.G. (copied from above)
Screenshots None provided
Desktop (please complete the following information): Running on v0.22.0 on OSX, VSCode version 1.49.2
Log _None provided - entry is successfully submitted.
Additional Info As an initial investigation, it looks like the call to
store.state.jira.addWorkLog
within/src/commands/issue-add-worklog.ts
is calling without any sort of 'start' parameter, just theissueKey
,timeSpentSeconds
andcomment
. Digging down into this method I cannot see that it accepts any other parameters, so the library/interface may need updating to support?Question - Does the API even support this? Other members are using the API to support timeStart events - so need to investigate.