초기 커밋
This commit is contained in:
29
app/processing/pipelines/report_pipeline.py
Normal file
29
app/processing/pipelines/report_pipeline.py
Normal file
@@ -0,0 +1,29 @@
|
||||
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
|
||||
Reference in New Issue
Block a user