feat: add a metric to monitor daily unique users (#19236)

#19234
This commit is contained in:
FlorentMair80
2025-11-17 15:31:24 -05:00
committed by GitHub
parent e76f72576e
commit 58cff5e482
2 changed files with 22 additions and 0 deletions
+7
View File
@@ -325,6 +325,13 @@ class UsersTable:
except Exception:
return None
def get_num_users_active_today(self) -> Optional[int]:
with get_db() as db:
current_timestamp = int(datetime.datetime.now().timestamp())
today_midnight_timestamp = current_timestamp - (current_timestamp % 86400)
query = db.query(User).filter(User.last_active_at > today_midnight_timestamp)
return query.count()
def update_user_role_by_id(self, id: str, role: str) -> Optional[UserModel]:
try:
with get_db() as db: