초기 커밋
This commit is contained in:
0
app/models/mongodb/__init__.py
Normal file
0
app/models/mongodb/__init__.py
Normal file
24
app/models/mongodb/analytics_result.py
Normal file
24
app/models/mongodb/analytics_result.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from beanie import Document
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
class AnalyticsResult(Document):
|
||||
analysis_type: str
|
||||
parameters: dict = Field(default_factory=dict)
|
||||
result: dict = Field(default_factory=dict)
|
||||
device_id: str | None = None
|
||||
period_start: datetime | None = None
|
||||
period_end: datetime | None = None
|
||||
created_at: datetime = Field(default_factory=datetime.utcnow)
|
||||
|
||||
class Settings:
|
||||
name = "analytics_results"
|
||||
indexes = [
|
||||
"analysis_type",
|
||||
"device_id",
|
||||
[("created_at", -1)],
|
||||
]
|
||||
27
app/models/mongodb/device_log.py
Normal file
27
app/models/mongodb/device_log.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from beanie import Document
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
class DeviceLog(Document):
|
||||
device_id: str
|
||||
event_type: str
|
||||
payload: dict = Field(default_factory=dict)
|
||||
ip_address: str | None = None
|
||||
timestamp: datetime = Field(default_factory=datetime.utcnow)
|
||||
|
||||
class Settings:
|
||||
name = "device_logs"
|
||||
indexes = [
|
||||
"device_id",
|
||||
"event_type",
|
||||
[("timestamp", -1)],
|
||||
]
|
||||
# TTL: 90일 후 자동 삭제
|
||||
timeseries = {
|
||||
"timeField": "timestamp",
|
||||
"expireAfterSeconds": 90 * 24 * 3600,
|
||||
}
|
||||
24
app/models/mongodb/notification.py
Normal file
24
app/models/mongodb/notification.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from beanie import Document
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
class Notification(Document):
|
||||
user_id: int
|
||||
title: str
|
||||
message: str
|
||||
notification_type: str = "info"
|
||||
is_read: bool = False
|
||||
read_at: datetime | None = None
|
||||
created_at: datetime = Field(default_factory=datetime.utcnow)
|
||||
|
||||
class Settings:
|
||||
name = "notifications"
|
||||
indexes = [
|
||||
"user_id",
|
||||
[("user_id", 1), ("is_read", 1)],
|
||||
[("created_at", -1)],
|
||||
]
|
||||
20
app/models/mongodb/telemetry.py
Normal file
20
app/models/mongodb/telemetry.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from beanie import Document
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
class TelemetryData(Document):
|
||||
device_id: str
|
||||
metrics: dict = Field(default_factory=dict)
|
||||
timestamp: datetime = Field(default_factory=datetime.utcnow)
|
||||
|
||||
class Settings:
|
||||
name = "telemetry_data"
|
||||
indexes = [
|
||||
"device_id",
|
||||
[("timestamp", -1)],
|
||||
[("device_id", 1), ("timestamp", -1)],
|
||||
]
|
||||
Reference in New Issue
Block a user