Improve the frontend and fix TODOs
This commit is contained in:
@@ -159,9 +159,37 @@ async def get_supplier_performance_metrics(
|
||||
):
|
||||
"""Get performance metrics for a supplier"""
|
||||
try:
|
||||
# TODO: Implement get_supplier_performance_metrics in service
|
||||
# For now, return empty list
|
||||
metrics = []
|
||||
from app.models.performance import SupplierPerformanceMetric
|
||||
from sqlalchemy import select, and_, desc
|
||||
|
||||
# Build query for performance metrics
|
||||
query = select(SupplierPerformanceMetric).where(
|
||||
and_(
|
||||
SupplierPerformanceMetric.supplier_id == supplier_id,
|
||||
SupplierPerformanceMetric.tenant_id == tenant_id
|
||||
)
|
||||
)
|
||||
|
||||
# Apply filters
|
||||
if metric_type:
|
||||
query = query.where(SupplierPerformanceMetric.metric_type == metric_type)
|
||||
|
||||
if date_from:
|
||||
query = query.where(SupplierPerformanceMetric.calculated_at >= date_from)
|
||||
|
||||
if date_to:
|
||||
query = query.where(SupplierPerformanceMetric.calculated_at <= date_to)
|
||||
|
||||
# Order by most recent and apply limit
|
||||
query = query.order_by(desc(SupplierPerformanceMetric.calculated_at)).limit(limit)
|
||||
|
||||
result = await db.execute(query)
|
||||
metrics = result.scalars().all()
|
||||
|
||||
logger.info("Retrieved performance metrics",
|
||||
tenant_id=str(tenant_id),
|
||||
supplier_id=str(supplier_id),
|
||||
count=len(metrics))
|
||||
|
||||
return metrics
|
||||
|
||||
@@ -227,9 +255,39 @@ async def get_supplier_alerts(
|
||||
):
|
||||
"""Get supplier alerts with filtering"""
|
||||
try:
|
||||
# TODO: Implement get_supplier_alerts in service
|
||||
# For now, return empty list
|
||||
alerts = []
|
||||
from app.models.performance import SupplierAlert
|
||||
from sqlalchemy import select, and_, desc
|
||||
|
||||
# Build query for alerts
|
||||
query = select(SupplierAlert).where(
|
||||
SupplierAlert.tenant_id == tenant_id
|
||||
)
|
||||
|
||||
# Apply filters
|
||||
if supplier_id:
|
||||
query = query.where(SupplierAlert.supplier_id == supplier_id)
|
||||
|
||||
if alert_type:
|
||||
query = query.where(SupplierAlert.alert_type == alert_type)
|
||||
|
||||
if severity:
|
||||
query = query.where(SupplierAlert.severity == severity)
|
||||
|
||||
if date_from:
|
||||
query = query.where(SupplierAlert.created_at >= date_from)
|
||||
|
||||
if date_to:
|
||||
query = query.where(SupplierAlert.created_at <= date_to)
|
||||
|
||||
# Order by most recent and apply limit
|
||||
query = query.order_by(desc(SupplierAlert.created_at)).limit(limit)
|
||||
|
||||
result = await db.execute(query)
|
||||
alerts = result.scalars().all()
|
||||
|
||||
logger.info("Retrieved supplier alerts",
|
||||
tenant_id=str(tenant_id),
|
||||
count=len(alerts))
|
||||
|
||||
return alerts
|
||||
|
||||
|
||||
Reference in New Issue
Block a user