Skip to content

Commit 6ee14d3

Browse files
authored
Multithreading in linking multiple issues (#66)
* Changed the linking of multiple issue functianlity with usage of multithreading to speed up the results * Formatted code * Change log modified to minor version instead of patch version * Changed pack version * Added inward and outward keys in output for better debug * Code formatting
1 parent 7ba2014 commit 6ee14d3

File tree

5 files changed

+52
-18
lines changed

5 files changed

+52
-18
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 2.5.0
4+
5+
- Added multithreading in linking multiple issue functionality to speed up the response.
6+
37
## 2.4.2
48

59
- Update `formatters.py` to include `priority` field

actions/bulk_link_issue.py

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,50 @@
1+
import threading
2+
from threading import Semaphore
13
from lib.base import BaseJiraAction
24

3-
__all__ = [
4-
'BulkLinkJiraIssueAction'
5-
]
6-
75

86
class BulkLinkJiraIssueAction(BaseJiraAction):
7+
def link_issues(
8+
self,
9+
semaphore,
10+
issue_key=None,
11+
target_issue=None,
12+
direction=None,
13+
link_type=None,
14+
):
15+
with semaphore:
16+
outward_issue_key = ""
17+
inward_issue_key = ""
18+
if direction == "outward":
19+
outward_issue_key = issue_key
20+
inward_issue_key = target_issue
21+
response = self._client.create_issue_link(
22+
link_type, inward_issue_key, outward_issue_key
23+
)
24+
25+
if direction == "inward":
26+
inward_issue_key = issue_key
27+
outward_issue_key = target_issue
28+
response = self._client.create_issue_link(
29+
link_type, inward_issue_key, outward_issue_key
30+
)
31+
response_output = {
32+
"inward_issue": inward_issue_key,
33+
"outward_issue": outward_issue_key,
34+
"response": response,
35+
}
36+
print(response_output)
37+
38+
def run(self, issue_key_list, target_issue, direction, link_type):
39+
threads = list()
40+
semaphore = Semaphore(10)
41+
for issue_key in issue_key_list:
42+
x = threading.Thread(
43+
target=self.link_issues,
44+
args=(semaphore, issue_key, target_issue, direction, link_type),
45+
)
46+
threads.append(x)
47+
x.start()
948

10-
def run(self, issue_key_list=None, target_issue=None, direction=None, link_type=None):
11-
if direction == 'outward':
12-
inward_issue_key = target_issue
13-
for outward_issue_key in issue_key_list:
14-
issue = self._client.create_issue_link(link_type, inward_issue_key,
15-
outward_issue_key)
16-
if direction == 'inward':
17-
outward_issue_key = target_issue
18-
for inward_issue_key in issue_key_list:
19-
issue = self._client.create_issue_link(link_type, inward_issue_key,
20-
outward_issue_key)
21-
return issue
49+
for thread in threads:
50+
thread.join()

actions/bulk_link_issue.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ parameters:
2525
type: string
2626
description: The type of link to create.
2727
required: true
28-
default: relates
28+
default: relates to

actions/link_issue.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ parameters:
1717
type: string
1818
description: The type of link to create.
1919
required: true
20+
default: relates to

pack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ keywords:
66
- issues
77
- ticket management
88
- project management
9-
version: 2.4.2
9+
version: 2.5.0
1010
python_versions:
1111
- "3"
1212
author : StackStorm, Inc.

0 commit comments

Comments
 (0)