feat: Add JiraAnalysisResponse model and update handlers to use it for analysis record serialization
Some checks are pending
CI/CD Pipeline / test (push) Waiting to run
Some checks are pending
CI/CD Pipeline / test (push) Waiting to run
This commit is contained in:
parent
1de9f46517
commit
1ff74e3ffb
@ -2,7 +2,7 @@ from fastapi import APIRouter, Request, HTTPException, Depends
|
|||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
from typing import Dict, Any
|
from typing import Dict, Any
|
||||||
import config
|
import config
|
||||||
from llm.models import LLMResponse, JiraWebhookPayload
|
from llm.models import LLMResponse, JiraWebhookPayload, JiraAnalysisResponse
|
||||||
from database.database import get_db_session # Removed Session import here
|
from database.database import get_db_session # Removed Session import here
|
||||||
from sqlalchemy.orm import Session # Added correct SQLAlchemy import
|
from sqlalchemy.orm import Session # Added correct SQLAlchemy import
|
||||||
from database.crud import get_all_analysis_records, delete_all_analysis_records, get_analysis_by_id, create_analysis_record
|
from database.crud import get_all_analysis_records, delete_all_analysis_records, get_analysis_by_id, create_analysis_record
|
||||||
@ -86,7 +86,4 @@ async def get_analysis_record_endpoint(record_id: int, db: Session = Depends(get
|
|||||||
record = get_analysis_by_id(db, record_id)
|
record = get_analysis_by_id(db, record_id)
|
||||||
if not record:
|
if not record:
|
||||||
raise HTTPException(status_code=404, detail="Analysis record not found")
|
raise HTTPException(status_code=404, detail="Analysis record not found")
|
||||||
return JSONResponse(
|
return JiraAnalysisResponse.model_validate(record)
|
||||||
status_code=200,
|
|
||||||
content=record.dict() # Ensure proper data serialization
|
|
||||||
)
|
|
||||||
BIN
jira_analyses.db
BIN
jira_analyses.db
Binary file not shown.
@ -53,4 +53,19 @@ class AnalysisFlags(BaseModel):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to track model usage: {e}")
|
logger.error(f"Failed to track model usage: {e}")
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
class JiraAnalysisResponse(BaseModel):
|
||||||
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
id: int
|
||||||
|
issue_key: str
|
||||||
|
status: str
|
||||||
|
issue_summary: str
|
||||||
|
request_payload: dict
|
||||||
|
analysis_result: Optional[dict] = None
|
||||||
|
created_at: datetime
|
||||||
|
updated_at: datetime
|
||||||
|
error_message: Optional[str] = None
|
||||||
|
raw_response: Optional[dict] = None
|
||||||
Loading…
x
Reference in New Issue
Block a user