Skip to content

Fix jira command after migration #20

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions commanderbot/ext/jira/jira_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from datetime import datetime
from typing import Optional
from typing import Any, Optional

import aiohttp

Expand All @@ -27,13 +27,20 @@ def __init__(self, url: Optional[str]):

async def _request_issue_data(self, base_url: str, issue_id: str) -> dict:
try:
issue_url: str = f"{base_url}/rest/api/latest/issue/{issue_id}"
url: str = f"{base_url}/api/jql-search-post"
headers: dict[str, str] = {"User-Agent": constants.USER_AGENT}
request_data: dict[str, Any] = {
"advanced": True,
"project": issue_id.split("-")[0],
"search": f"key = {issue_id}",
"maxResults": 1,
}
async with aiohttp.ClientSession() as session:
async with session.get(
issue_url, headers=headers, raise_for_status=True
async with session.post(
url, headers=headers, json=request_data, raise_for_status=True
) as response:
return await response.json()
response_data = await response.json()
return response_data["issues"][0]

except aiohttp.InvalidURL:
raise InvalidURL(issue_id)
Expand Down Expand Up @@ -77,9 +84,8 @@ async def get_issue(self, query: JiraQuery) -> JiraIssue:
return JiraIssue(
issue_id=issue_id,
url=f"{base_url}/browse/{issue_id}",
icon_url=f"{base_url}/jira-favicon-hires.png",
icon_url=f"{base_url}/{issue_id.split("-")[0].lower()}_icon.png",
summary=fields["summary"],
reporter=fields["reporter"]["displayName"],
assignee=assignee,
created=datetime.strptime(fields["created"], "%Y-%m-%dT%H:%M:%S.%f%z"),
updated=datetime.strptime(fields["updated"], "%Y-%m-%dT%H:%M:%S.%f%z"),
Expand Down
2 changes: 0 additions & 2 deletions commanderbot/ext/jira/jira_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class JiraIssue:
url: str
icon_url: str
summary: str
reporter: str
assignee: str
created: datetime
updated: datetime
Expand All @@ -53,7 +52,6 @@ class JiraIssue:
@property
def fields(self) -> dict:
return {
"Reported By": self.reporter,
"Assigned To": self.assignee,
"Created": format_dt(self.created, style="R"),
"Updated": format_dt(self.updated, style="R"),
Expand Down