-
Notifications
You must be signed in to change notification settings - Fork 704
[WIP] [JIRA] new method get_issue_status_changelog + docs + example +small improvement get_issue #1357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] [JIRA] new method get_issue_status_changelog + docs + example +small improvement get_issue #1357
Changes from 27 commits
2e8e1b0
715463b
4db577a
e13b5ba
9fd7ae4
f695346
6f3c1f6
7fd73d8
ef752ab
999de01
2edee0c
fe7c1f1
bf7dcb4
7d6b0a0
a56b1be
0802a35
c23e7cd
e8e8959
8c2824b
9b1c9c4
08d4acb
20cae0b
26cf691
4cc2a03
10ee67e
273401b
b70f618
6bcd2c0
6a83b0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1082,13 +1082,7 @@ def issue(self, key, fields="*all", expand=None): | |
| params["expand"] = expand | ||
| return self.get(url, params=params) | ||
|
|
||
| def get_issue( | ||
| self, | ||
| issue_id_or_key, | ||
| fields=None, | ||
| properties=None, | ||
| update_history=True, | ||
| ): | ||
| def get_issue(self, issue_id_or_key, fields=None, properties=None, update_history=True, expand=None): | ||
| """ | ||
| Returns a full representation of the issue for the given issue key | ||
| By default, all fields are returned in this get-issue resource | ||
|
|
@@ -1097,6 +1091,7 @@ def get_issue( | |
| :param fields: str | ||
| :param properties: str | ||
| :param update_history: bool | ||
| :param expand: str | ||
| :return: issue | ||
| """ | ||
| base_url = self.resource_url("issue") | ||
|
|
@@ -1109,6 +1104,8 @@ def get_issue( | |
| params["fields"] = fields | ||
| if properties is not None: | ||
| params["properties"] = properties | ||
| if expand: | ||
| params["expand"] = expand | ||
| if update_history is True: | ||
| params["updateHistory"] = "true" | ||
| if update_history is False: | ||
|
|
@@ -1867,6 +1864,20 @@ def set_issue_status(self, issue_key, status_name, fields=None, update=None): | |
| data["update"] = update | ||
| return self.post(url, data=data) | ||
|
|
||
| def get_issue_status_changelog(self, issue_id): | ||
| # Get the issue details with changelog | ||
| issue_id = self.get_issue(issue_id, expand="changelog") | ||
|
||
| status_change_history = [] | ||
| for history in issue_id["changelog"]["histories"]: | ||
| for item in history["items"]: | ||
| # Check if the item is a status change | ||
| if item["field"] == "status": | ||
| status_change_history.append( | ||
| {"from": item["fromString"], "to": item["toString"], "date": history["created"]} | ||
| ) | ||
|
|
||
| return status_change_history | ||
|
|
||
| def set_issue_status_by_transition_id(self, issue_key, transition_id): | ||
| """ | ||
| Setting status by transition_id | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from atlassian import Jira | ||
|
|
||
| jira_cloud = Jira(url="<url>", username="username", password="password") | ||
| jira_dc = Jira(url="url", token="<token>>") | ||
|
|
||
| # example use | ||
| jira_cloud.get_issue_status_changelog("TEST-1") | ||
| # example output: | ||
| # [{'from': 'Closed', 'to': 'In Progress', 'date': '2024-03-17T17:22:29.524-0500'}, {'from': 'In Progress', 'to': 'Closed', 'date': '2024-03-17T14:33:07.317-0500'}, {'from': 'In Progress', 'to': 'In Progress', 'date': '2024-03-16T09:25:52.033-0500'}, {'from': 'To Do', 'to': 'In Progress', 'date': '2024-03-14T19:25:02.511-0500'}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would also write:
instead of: