-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
7ba2014
commit 6ee14d3
Showing
5 changed files
with
52 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,50 @@ | ||
import threading | ||
from threading import Semaphore | ||
from lib.base import BaseJiraAction | ||
|
||
__all__ = [ | ||
'BulkLinkJiraIssueAction' | ||
] | ||
|
||
|
||
class BulkLinkJiraIssueAction(BaseJiraAction): | ||
def link_issues( | ||
self, | ||
semaphore, | ||
issue_key=None, | ||
target_issue=None, | ||
direction=None, | ||
link_type=None, | ||
): | ||
with semaphore: | ||
outward_issue_key = "" | ||
inward_issue_key = "" | ||
if direction == "outward": | ||
outward_issue_key = issue_key | ||
inward_issue_key = target_issue | ||
response = self._client.create_issue_link( | ||
link_type, inward_issue_key, outward_issue_key | ||
) | ||
|
||
if direction == "inward": | ||
inward_issue_key = issue_key | ||
outward_issue_key = target_issue | ||
response = self._client.create_issue_link( | ||
link_type, inward_issue_key, outward_issue_key | ||
) | ||
response_output = { | ||
"inward_issue": inward_issue_key, | ||
"outward_issue": outward_issue_key, | ||
"response": response, | ||
} | ||
print(response_output) | ||
|
||
def run(self, issue_key_list, target_issue, direction, link_type): | ||
threads = list() | ||
semaphore = Semaphore(10) | ||
for issue_key in issue_key_list: | ||
x = threading.Thread( | ||
target=self.link_issues, | ||
args=(semaphore, issue_key, target_issue, direction, link_type), | ||
) | ||
threads.append(x) | ||
x.start() | ||
|
||
def run(self, issue_key_list=None, target_issue=None, direction=None, link_type=None): | ||
if direction == 'outward': | ||
inward_issue_key = target_issue | ||
for outward_issue_key in issue_key_list: | ||
issue = self._client.create_issue_link(link_type, inward_issue_key, | ||
outward_issue_key) | ||
if direction == 'inward': | ||
outward_issue_key = target_issue | ||
for inward_issue_key in issue_key_list: | ||
issue = self._client.create_issue_link(link_type, inward_issue_key, | ||
outward_issue_key) | ||
return issue | ||
for thread in threads: | ||
thread.join() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ parameters: | |
type: string | ||
description: The type of link to create. | ||
required: true | ||
default: relates to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters