Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
MMFG
JIRA Logger
Commits
92ba4fdc
Unverified
Commit
92ba4fdc
authored
1 month ago
by
Cristiano Serri
Browse files
Options
Download
Email Patches
Plain Diff
Fix per nuova versione API Jira OT
parent
f8856f09
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
jira_adapter.py
+4
-1
jira_adapter.py
jira_ot.py
+16
-4
jira_ot.py
myjira.py
+16
-4
myjira.py
with
36 additions
and
9 deletions
+36
-9
jira_adapter.py
View file @
92ba4fdc
...
...
@@ -66,7 +66,10 @@ class JiraAdapter(object):
w
for
w
in
worklogs
if
(
(
w
.
author
.
name
if
hasattr
(
w
.
author
,
'name'
)
else
w
.
author
.
displayName
)
==
display_name
if
not
isinstance
(
w
,
dict
)
else
w
[
'author'
].
get
(
'displayName'
)
==
conf
.
get
(
'displayName'
)
else
(
w
[
'author'
].
get
(
'displayName'
)
==
conf
.
get
(
'displayName'
)
or
w
[
'author'
].
get
(
'accountId'
)
==
conf
.
get
(
'authorAccountId'
)
)
)
]
if
lista_worklogs
:
...
...
This diff is collapsed.
Click to expand it.
jira_ot.py
View file @
92ba4fdc
...
...
@@ -2,21 +2,33 @@ import json
from
config
import
conf
import
requests
from
jira_adapter
import
JiraAdapter
from
requests.auth
import
HTTPBasicAuth
from
constants
import
jira_server
class
JiraOT
(
JiraAdapter
):
def
add_worklog
(
self
,
issue
,
time_spent_seconds
=
None
,
comment
=
None
,
started
=
None
,
user
=
None
,
ufficio_remoto
=
"Ufficio"
):
issue_id
=
requests
.
request
(
method
=
"GET"
,
url
=
f
"
{
jira_server
[
self
.
sistema
]
}
rest/api/3/issue/
{
issue
}
"
,
data
=
{},
headers
=
{
"Accept"
:
"application/json"
,
"Content-Type"
:
"application/json"
},
auth
=
HTTPBasicAuth
(
conf
[
'user'
],
conf
[
'password'
])
).
json
()[
'id'
]
res
=
requests
.
request
(
method
=
"POST"
,
url
=
"https://api.tempo.io/
core/3
/worklogs"
,
url
=
"https://api.tempo.io/
4
/worklogs"
,
headers
=
{
'Authorization'
:
f
"Bearer
{
conf
[
'tempo_token'
]
}
"
,
'Content-Type'
:
'application/json'
},
data
=
json
.
dumps
({
"issue
Key"
:
str
(
self
.
jira
.
issue
(
id
=
issue
).
id
)
,
"issue
Id"
:
issue_
id
,
"timeSpentSeconds"
:
int
(
time_spent_seconds
),
"startDate"
:
started
.
strftime
(
'%Y-%m-%d'
),
"startTime"
:
"08:00:00"
,
...
...
This diff is collapsed.
Click to expand it.
myjira.py
View file @
92ba4fdc
...
...
@@ -37,7 +37,7 @@ class MyJira(JIRA):
def
delete
(
self
):
requests
.
request
(
method
=
"DELETE"
,
url
=
f
"https://api.tempo.io/
core/3
/worklogs/
{
self
[
'tempoWorklogId'
]
}
"
,
url
=
f
"https://api.tempo.io/
4
/worklogs/
{
self
[
'tempoWorklogId'
]
}
"
,
headers
=
{
'Authorization'
:
f
'Bearer
{
conf
[
"tempo_token"
]
}
'
,
},
data
=
{}
)
...
...
@@ -48,14 +48,26 @@ class MyJira(JIRA):
offset
=
0
data_fine
=
self
.
_ultimo_del_mese
(
data_inizio
)
issue_id
=
requests
.
request
(
method
=
"GET"
,
url
=
f
"
{
jira_server
[
self
.
sistema
]
}
rest/api/3/issue/
{
issue
}
"
,
data
=
{},
headers
=
{
"Accept"
:
"application/json"
,
"Content-Type"
:
"application/json"
},
auth
=
HTTPBasicAuth
(
conf
[
'user'
],
conf
[
'password'
])
).
json
()[
'id'
]
print
(
f
'id issue =
{
issue_id
}
'
)
while
count
==
limit
:
response
=
requests
.
request
(
method
=
"GET"
,
url
=
f
"https://api.tempo.io/
core/3
/worklogs?issue=
{
issue
}
&offset=
{
offset
}
&limit=
{
limit
}
&from=
{
data_inizio
}
&to=
{
data_fine
}
"
,
url
=
f
"https://api.tempo.io/
4
/worklogs?issue
Id
=
{
issue
_id
}
&offset=
{
offset
}
&limit=
{
limit
}
&from=
{
data_inizio
}
&to=
{
data_fine
}
"
,
headers
=
{
'Authorization'
:
f
"Bearer
{
conf
[
'tempo_token'
]
}
"
,
},
data
=
{}
}
)
response_json
=
response
.
json
()
list_ret
+=
[
Worklog
(
x
)
for
x
in
response_json
[
'results'
]]
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help