Skip to content

Commit 065ae34

Browse files
authored
Fix Jira reindex methods and implement reindex_issue (closes #1610) (#1629)
- Fix reindex(): `if not indexing_type` was always False since it defaults to a non-empty string, so the type param was never sent. Changed to `if indexing_type`. - Fix reindex_status(): Jira returns 303 during active reindex which caused TooManyRedirects. Now uses allow_redirects=False. - Add allow_redirects parameter to rest_client.request() so callers can opt out of redirect following when needed. - Implement reindex_issue() which was previously a stub (just `pass`).
1 parent 521a67f commit 065ae34

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

atlassian/jira.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4648,7 +4648,7 @@ def reindex(
46484648
params["indexChangeHistory"] = change_history
46494649
if not worklogs:
46504650
params["indexWorklogs"] = worklogs
4651-
if not indexing_type:
4651+
if indexing_type:
46524652
params["type"] = indexing_type
46534653
url = self.resource_url("reindex")
46544654
return self.post(url, params=params)
@@ -4676,7 +4676,8 @@ def reindex_status(self) -> T_resp_json:
46764676
:return:
46774677
"""
46784678
url = self.resource_url("reindex")
4679-
return self.get(url)
4679+
response = self.request("GET", path=url, allow_redirects=False)
4680+
return response.json()
46804681

46814682
def reindex_project(self, project_key: str) -> T_resp_json:
46824683
return self.post(
@@ -4685,8 +4686,15 @@ def reindex_project(self, project_key: str) -> T_resp_json:
46854686
headers=self.form_token_headers,
46864687
)
46874688

4688-
def reindex_issue(self, list_of_: list) -> None:
4689-
pass
4689+
def reindex_issue(self, issue_ids: list) -> T_resp_json:
4690+
"""
4691+
Reindex specific issues by their IDs.
4692+
:param issue_ids: list of issue IDs (numeric) to reindex
4693+
:return:
4694+
"""
4695+
url = self.resource_url("reindex/issue")
4696+
params = {"issueId": ",".join(str(i) for i in issue_ids)}
4697+
return self.post(url, params=params)
46904698

46914699
def index_checker(self, max_results: int = 100) -> T_resp_json:
46924700
"""

atlassian/rest_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ def request(
440440
trailing: Optional[bool] = None,
441441
absolute: bool = False,
442442
advanced_mode: bool = False,
443+
allow_redirects: bool = True,
443444
) -> Response:
444445
"""
445446
@@ -493,6 +494,7 @@ def request(
493494
files=files,
494495
proxies=self.proxies,
495496
cert=self.cert,
497+
allow_redirects=allow_redirects,
496498
)
497499
continue_retries = retry_handler(response)
498500
if continue_retries:

0 commit comments

Comments
 (0)