mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-28 18:36:23 +02:00
fix: resolve graphql complexity, json extraction, kb sync, and ui prefill for linear HIL
This commit is contained in:
parent
d4e2ebb99f
commit
c8413ee2bf
12 changed files with 269 additions and 213 deletions
|
|
@ -78,7 +78,7 @@ class LinearKBSyncService:
|
|||
issue_identifier = formatted_issue.get("identifier", "")
|
||||
issue_title = formatted_issue.get("title", "")
|
||||
state = formatted_issue.get("state", "Unknown")
|
||||
priority = issue_raw.get("priority", 0)
|
||||
priority = issue_raw.get("priorityLabel", "Unknown")
|
||||
comment_count = len(formatted_issue.get("comments", []))
|
||||
description = formatted_issue.get("description", "")
|
||||
|
||||
|
|
@ -125,16 +125,20 @@ class LinearKBSyncService:
|
|||
issue_content, search_space_id
|
||||
)
|
||||
document.embedding = summary_embedding
|
||||
from sqlalchemy.orm.attributes import flag_modified
|
||||
|
||||
document.document_metadata = {
|
||||
**document.document_metadata,
|
||||
**(document.document_metadata or {}),
|
||||
"issue_id": issue_id,
|
||||
"issue_identifier": issue_identifier,
|
||||
"issue_title": issue_title,
|
||||
"state": state,
|
||||
"priority": priority,
|
||||
"comment_count": comment_count,
|
||||
"indexed_at": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
||||
"connector_id": connector_id,
|
||||
}
|
||||
flag_modified(document, "document_metadata")
|
||||
safe_set_chunks(document, chunks)
|
||||
document.updated_at = get_current_timestamp()
|
||||
|
||||
|
|
@ -159,7 +163,7 @@ class LinearKBSyncService:
|
|||
query = """
|
||||
query LinearIssueSync($id: String!) {
|
||||
issue(id: $id) {
|
||||
id identifier title description priority
|
||||
id identifier title description priority priorityLabel
|
||||
createdAt updatedAt url
|
||||
state { id name type color }
|
||||
creator { id name email }
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ class LinearToolMetadataService:
|
|||
"""Fetch all teams with their states, members, and labels."""
|
||||
query = """
|
||||
query {
|
||||
teams {
|
||||
teams(first: 25) {
|
||||
nodes {
|
||||
id name key
|
||||
states { nodes { id name type color position } }
|
||||
|
|
@ -248,7 +248,19 @@ class LinearToolMetadataService:
|
|||
}
|
||||
"""
|
||||
result = await client.execute_graphql_query(query)
|
||||
return result.get("data", {}).get("teams", {}).get("nodes", [])
|
||||
raw_teams = result.get("data", {}).get("teams", {}).get("nodes", [])
|
||||
|
||||
return [
|
||||
{
|
||||
"id": t.get("id"),
|
||||
"name": t.get("name"),
|
||||
"key": t.get("key"),
|
||||
"states": (t.get("states") or {}).get("nodes", []),
|
||||
"members": (t.get("members") or {}).get("nodes", []),
|
||||
"labels": (t.get("labels") or {}).get("nodes", []),
|
||||
}
|
||||
for t in raw_teams
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
async def _fetch_issue_context(
|
||||
|
|
@ -296,11 +308,15 @@ class LinearToolMetadataService:
|
|||
SearchSourceConnector.user_id == user_id,
|
||||
or_(
|
||||
func.lower(
|
||||
Document.document_metadata["issue_title"].astext
|
||||
Document.document_metadata.op("->>")(
|
||||
"issue_title"
|
||||
)
|
||||
)
|
||||
== ref_lower,
|
||||
func.lower(
|
||||
Document.document_metadata["issue_identifier"].astext
|
||||
Document.document_metadata.op("->>")(
|
||||
"issue_identifier"
|
||||
)
|
||||
)
|
||||
== ref_lower,
|
||||
func.lower(Document.title) == ref_lower,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue