30 lines
939 B
Python
30 lines
939 B
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from app.models.mongodb.analytics_result import AnalyticsResult
|
|
from app.processing.analyzers.device_analyzer import analyze_device_status
|
|
from app.processing.analyzers.trend_analyzer import analyze_trend
|
|
|
|
|
|
async def generate_device_report(
|
|
device_id: str, start: datetime, end: datetime
|
|
) -> AnalyticsResult:
|
|
"""Generate a comprehensive device report."""
|
|
status_report = await analyze_device_status(device_id, start, end)
|
|
trend_report = await analyze_trend(device_id, start, end)
|
|
|
|
result = AnalyticsResult(
|
|
analysis_type="device_report",
|
|
device_id=device_id,
|
|
parameters={"start": start.isoformat(), "end": end.isoformat()},
|
|
result={
|
|
"status": status_report,
|
|
"trends": trend_report,
|
|
},
|
|
period_start=start,
|
|
period_end=end,
|
|
)
|
|
await result.insert()
|
|
return result
|