Skip to content

Commit 2b615bb

Browse files
committed
events / admin events fix
1 parent c3e6aed commit 2b615bb

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

backend/app/schemas_pydantic/admin_events.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pydantic import BaseModel, ConfigDict, Field
55

66
from app.domain.enums.events import EventType
7+
from app.schemas_pydantic.events import HourlyEventCountSchema
78

89

910
class EventFilter(BaseModel):
@@ -97,14 +98,23 @@ class EventDeleteResponse(BaseModel):
9798
event_id: str
9899

99100

101+
class UserEventCountSchema(BaseModel):
102+
"""User event count schema"""
103+
104+
model_config = ConfigDict(from_attributes=True)
105+
106+
user_id: str
107+
event_count: int
108+
109+
100110
class EventStatsResponse(BaseModel):
101111
"""Response model for event statistics"""
102112

103113
model_config = ConfigDict(from_attributes=True)
104114

105115
total_events: int
106116
events_by_type: Dict[str, int]
107-
events_by_hour: List[Dict[str, Any]]
108-
top_users: List[Dict[str, Any]]
117+
events_by_hour: List[HourlyEventCountSchema]
118+
top_users: List[UserEventCountSchema]
109119
error_rate: float
110120
avg_processing_time: float

backend/app/schemas_pydantic/events.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414
from app.domain.enums.events import EventType
1515

1616

17+
class HourlyEventCountSchema(BaseModel):
18+
"""Hourly event count for statistics."""
19+
20+
model_config = ConfigDict(from_attributes=True)
21+
22+
hour: str
23+
count: int
24+
25+
1726
class EventMetadataResponse(BaseModel):
1827
"""Pydantic schema for event metadata in API responses."""
1928

@@ -205,7 +214,7 @@ class EventStatistics(BaseModel):
205214
total_events: int
206215
events_by_type: Dict[str, int]
207216
events_by_service: Dict[str, int]
208-
events_by_hour: List[Dict[str, Any]]
217+
events_by_hour: List[HourlyEventCountSchema]
209218
start_time: datetime | None = None
210219
end_time: datetime | None = None
211220

0 commit comments

Comments
 (0)