Skip to content

Commit a9f7326

Browse files
committed
Fix Jira reindex methods and implement reindex_issue (closes #1610)
- 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 63e744f commit a9f7326

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
@@ -4614,7 +4614,7 @@ def reindex(
46144614
params["indexChangeHistory"] = change_history
46154615
if not worklogs:
46164616
params["indexWorklogs"] = worklogs
4617-
if not indexing_type:
4617+
if indexing_type:
46184618
params["type"] = indexing_type
46194619
url = self.resource_url("reindex")
46204620
return self.post(url, params=params)
@@ -4642,7 +4642,8 @@ def reindex_status(self) -> T_resp_json:
46424642
:return:
46434643
"""
46444644
url = self.resource_url("reindex")
4645-
return self.get(url)
4645+
response = self.request("GET", path=url, allow_redirects=False)
4646+
return response.json()
46464647

46474648
def reindex_project(self, project_key: str) -> T_resp_json:
46484649
return self.post(
@@ -4651,8 +4652,15 @@ def reindex_project(self, project_key: str) -> T_resp_json:
46514652
headers=self.form_token_headers,
46524653
)
46534654

4654-
def reindex_issue(self, list_of_: list) -> None:
4655-
pass
4655+
def reindex_issue(self, issue_ids: list) -> T_resp_json:
4656+
"""
4657+
Reindex specific issues by their IDs.
4658+
:param issue_ids: list of issue IDs (numeric) to reindex
4659+
:return:
4660+
"""
4661+
url = self.resource_url("reindex/issue")
4662+
params = {"issueId": ",".join(str(i) for i in issue_ids)}
4663+
return self.post(url, params=params)
46564664

46574665
def index_checker(self, max_results: int = 100) -> T_resp_json:
46584666
"""

atlassian/rest_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ def request(
439439
trailing: Optional[bool] = None,
440440
absolute: bool = False,
441441
advanced_mode: bool = False,
442+
allow_redirects: bool = True,
442443
) -> Response:
443444
"""
444445
@@ -492,6 +493,7 @@ def request(
492493
files=files,
493494
proxies=self.proxies,
494495
cert=self.cert,
496+
allow_redirects=allow_redirects,
495497
)
496498
continue_retries = retry_handler(response)
497499
if continue_retries:

0 commit comments

Comments
 (0)