Sprint 2: Ticket Engine, SLA Engine, Photo Uploads, Category System #2

Merged
abiba-bot merged 7 commits from fm/denya-onecare-s2 into main 2026-07-23 18:55:00 +00:00
2 changed files with 5 additions and 7 deletions
Showing only changes of commit 31ae78ec07 - Show all commits
+1
View File
@@ -36,6 +36,7 @@ class TicketCreate(BaseModel):
class TicketUpdate(BaseModel):
status: str | None = None
note: str | None = None
unit_id: int | None = None
category_id: int | None = None
priority: str | None = None
+4 -7
View File
@@ -11,6 +11,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import selectinload
from app.models.ticket import Escalation, Ticket, TicketPhoto, TicketTimeline
from app.models.unit import Unit
from app.models.user import User
from app.services.sla import compute_sla_deadline, get_sla_status
@@ -174,8 +175,8 @@ async def list_tickets(
count_query = count_query.where(Ticket.priority == priority_filter)
if property_filter:
# Join unit to filter by property
query = query.join(Ticket.unit).where(Ticket.unit.has(property=property_filter))
count_query = count_query.join(Ticket.unit).where(Ticket.unit.has(property=property_filter))
query = query.join(Ticket.unit).where(Unit.property == property_filter)
count_query = count_query.join(Ticket.unit).where(Unit.property == property_filter)
if category_id:
query = query.where(Ticket.category_id == category_id)
count_query = count_query.where(Ticket.category_id == category_id)
@@ -268,7 +269,7 @@ async def update_ticket(
ticket.id,
from_status=old_status,
to_status=new_status,
note=data.get("note") or data.get("note"),
note=data.get("note"),
user_id=user.id if user else None,
)
@@ -293,7 +294,3 @@ async def update_ticket(
return ticket
async def get_ticket_with_sla(db: AsyncSession, ticket_id: int) -> Ticket:
"""Get a ticket and attach SLA status to it."""
ticket = await get_ticket(db, ticket_id)
return ticket