mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-08-29 07:04:16 +02:00
New metadata for Jira for KG (#4785)
* new metadata components * nits & tests
This commit is contained in:
@@ -87,6 +87,9 @@ class BasicExpertInfo(BaseModel):
|
|||||||
|
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
|
|
||||||
|
def get_email(self) -> str | None:
|
||||||
|
return self.email or None
|
||||||
|
|
||||||
def __eq__(self, other: Any) -> bool:
|
def __eq__(self, other: Any) -> bool:
|
||||||
if not isinstance(other, BasicExpertInfo):
|
if not isinstance(other, BasicExpertInfo):
|
||||||
return False
|
return False
|
||||||
|
@@ -60,6 +60,14 @@ _FIELD_KEY = "key"
|
|||||||
_FIELD_CREATED = "created"
|
_FIELD_CREATED = "created"
|
||||||
_FIELD_DUEDATE = "duedate"
|
_FIELD_DUEDATE = "duedate"
|
||||||
_FIELD_ISSUETYPE = "issuetype"
|
_FIELD_ISSUETYPE = "issuetype"
|
||||||
|
_FIELD_PARENT = "parent"
|
||||||
|
_FIELD_ASSIGNEE_EMAIL = "assignee_email"
|
||||||
|
_FIELD_REPORTER_EMAIL = "reporter_email"
|
||||||
|
_FIELD_PROJECT = "project"
|
||||||
|
_FIELD_PROJECT_NAME = "project_name"
|
||||||
|
_FIELD_UPDATED = "updated"
|
||||||
|
_FIELD_RESOLUTION_DATE = "resolutiondate"
|
||||||
|
_FIELD_RESOLUTION_DATE_KEY = "resolution_date"
|
||||||
|
|
||||||
|
|
||||||
def _perform_jql_search(
|
def _perform_jql_search(
|
||||||
@@ -131,6 +139,9 @@ def process_jira_issue(
|
|||||||
if basic_expert_info := best_effort_basic_expert_info(creator):
|
if basic_expert_info := best_effort_basic_expert_info(creator):
|
||||||
people.add(basic_expert_info)
|
people.add(basic_expert_info)
|
||||||
metadata_dict[_FIELD_REPORTER] = basic_expert_info.get_semantic_name()
|
metadata_dict[_FIELD_REPORTER] = basic_expert_info.get_semantic_name()
|
||||||
|
if email := basic_expert_info.get_email():
|
||||||
|
metadata_dict[_FIELD_REPORTER_EMAIL] = email
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
# Author should exist but if not, doesn't matter
|
# Author should exist but if not, doesn't matter
|
||||||
pass
|
pass
|
||||||
@@ -140,6 +151,8 @@ def process_jira_issue(
|
|||||||
if basic_expert_info := best_effort_basic_expert_info(assignee):
|
if basic_expert_info := best_effort_basic_expert_info(assignee):
|
||||||
people.add(basic_expert_info)
|
people.add(basic_expert_info)
|
||||||
metadata_dict[_FIELD_ASSIGNEE] = basic_expert_info.get_semantic_name()
|
metadata_dict[_FIELD_ASSIGNEE] = basic_expert_info.get_semantic_name()
|
||||||
|
if email := basic_expert_info.get_email():
|
||||||
|
metadata_dict[_FIELD_ASSIGNEE_EMAIL] = email
|
||||||
except Exception:
|
except Exception:
|
||||||
# Author should exist but if not, doesn't matter
|
# Author should exist but if not, doesn't matter
|
||||||
pass
|
pass
|
||||||
@@ -154,10 +167,32 @@ def process_jira_issue(
|
|||||||
metadata_dict[_FIELD_LABELS] = labels
|
metadata_dict[_FIELD_LABELS] = labels
|
||||||
if created := best_effort_get_field_from_issue(issue, _FIELD_CREATED):
|
if created := best_effort_get_field_from_issue(issue, _FIELD_CREATED):
|
||||||
metadata_dict[_FIELD_CREATED] = created
|
metadata_dict[_FIELD_CREATED] = created
|
||||||
|
if updated := best_effort_get_field_from_issue(issue, _FIELD_UPDATED):
|
||||||
|
metadata_dict[_FIELD_UPDATED] = updated
|
||||||
if duedate := best_effort_get_field_from_issue(issue, _FIELD_DUEDATE):
|
if duedate := best_effort_get_field_from_issue(issue, _FIELD_DUEDATE):
|
||||||
metadata_dict[_FIELD_DUEDATE] = duedate
|
metadata_dict[_FIELD_DUEDATE] = duedate
|
||||||
if issuetype := best_effort_get_field_from_issue(issue, _FIELD_ISSUETYPE):
|
if issuetype := best_effort_get_field_from_issue(issue, _FIELD_ISSUETYPE):
|
||||||
metadata_dict[_FIELD_ISSUETYPE] = issuetype.name
|
metadata_dict[_FIELD_ISSUETYPE] = issuetype.name
|
||||||
|
if resolutiondate := best_effort_get_field_from_issue(
|
||||||
|
issue, _FIELD_RESOLUTION_DATE
|
||||||
|
):
|
||||||
|
metadata_dict[_FIELD_RESOLUTION_DATE_KEY] = resolutiondate
|
||||||
|
|
||||||
|
try:
|
||||||
|
parent = best_effort_get_field_from_issue(issue, _FIELD_PARENT)
|
||||||
|
if parent:
|
||||||
|
metadata_dict[_FIELD_PARENT] = parent.key
|
||||||
|
except Exception:
|
||||||
|
# Parent should exist but if not, doesn't matter
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
project = best_effort_get_field_from_issue(issue, _FIELD_PROJECT)
|
||||||
|
if project:
|
||||||
|
metadata_dict[_FIELD_PROJECT_NAME] = project.name
|
||||||
|
metadata_dict[_FIELD_PROJECT] = project.key
|
||||||
|
except Exception:
|
||||||
|
# Project should exist.
|
||||||
|
logger.error(f"Project should exist but does not for {issue.key}")
|
||||||
|
|
||||||
return Document(
|
return Document(
|
||||||
id=page_url,
|
id=page_url,
|
||||||
|
@@ -59,11 +59,19 @@ def test_jira_connector_basic(
|
|||||||
assert story.source == DocumentSource.JIRA
|
assert story.source == DocumentSource.JIRA
|
||||||
assert story.metadata == {
|
assert story.metadata == {
|
||||||
"priority": "Medium",
|
"priority": "Medium",
|
||||||
"status": "Backlog",
|
"status": "Done",
|
||||||
|
"resolution": "Done",
|
||||||
|
"resolution_date": "2025-05-29T15:33:31.031-0700",
|
||||||
"reporter": "Chris Weaver",
|
"reporter": "Chris Weaver",
|
||||||
"assignee": "Chris Weaver",
|
"assignee": "Chris Weaver",
|
||||||
"issuetype": "Story",
|
"issuetype": "Story",
|
||||||
"created": "2025-04-16T16:44:06.716-0700",
|
"created": "2025-04-16T16:44:06.716-0700",
|
||||||
|
"reporter_email": "chris@onyx.app",
|
||||||
|
"assignee_email": "chris@onyx.app",
|
||||||
|
"project_name": "DailyConnectorTestProject",
|
||||||
|
"project": "AS",
|
||||||
|
"parent": "AS-4",
|
||||||
|
"updated": "2025-05-29T15:33:31.085-0700",
|
||||||
}
|
}
|
||||||
assert story.secondary_owners is None
|
assert story.secondary_owners is None
|
||||||
assert story.title == "AS-3 test123small"
|
assert story.title == "AS-3 test123small"
|
||||||
@@ -86,6 +94,11 @@ def test_jira_connector_basic(
|
|||||||
"assignee": "Chris Weaver",
|
"assignee": "Chris Weaver",
|
||||||
"issuetype": "Epic",
|
"issuetype": "Epic",
|
||||||
"created": "2025-04-16T16:55:53.068-0700",
|
"created": "2025-04-16T16:55:53.068-0700",
|
||||||
|
"reporter_email": "founders@onyx.app",
|
||||||
|
"assignee_email": "chris@onyx.app",
|
||||||
|
"project_name": "DailyConnectorTestProject",
|
||||||
|
"project": "AS",
|
||||||
|
"updated": "2025-05-29T14:43:05.312-0700",
|
||||||
}
|
}
|
||||||
assert epic.secondary_owners is None
|
assert epic.secondary_owners is None
|
||||||
assert epic.title == "AS-4 EPIC"
|
assert epic.title == "AS-4 EPIC"
|
||||||
|
Reference in New Issue
Block a user