Skip to content

Commit ceaad4b

Browse files
committed
fixes
1 parent 518da12 commit ceaad4b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

backend/app/db/repositories/admin/admin_events_repository.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,17 @@ async def get_event_stats(self, hours: int = 24) -> EventStatistics:
9696
start_time = datetime.now(timezone.utc) - timedelta(hours=hours)
9797

9898
# Overview stats pipeline
99+
# Note: monggregate doesn't have S.add_to_set - use raw dict syntax
99100
overview_pipeline = (
100101
Pipeline()
101102
.match({EventDocument.timestamp: {"$gte": start_time}})
102103
.group(
103104
by=None,
104105
query={
105106
"total_events": S.sum(1),
106-
"event_types": S.add_to_set(S.field(EventDocument.event_type)),
107-
"unique_users": S.add_to_set(S.field(EventDocument.metadata.user_id)),
108-
"services": S.add_to_set(S.field(EventDocument.metadata.service_name)),
107+
"event_types": {"$addToSet": S.field(EventDocument.event_type)},
108+
"unique_users": {"$addToSet": S.field(EventDocument.metadata.user_id)},
109+
"services": {"$addToSet": S.field(EventDocument.metadata.service_name)},
109110
},
110111
)
111112
.project(

0 commit comments

Comments
 (0)