mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-22 08:38:13 +02:00
fix: add error in cloudonix cdr report
This commit is contained in:
parent
b1c982a52e
commit
e9c5da16c5
7 changed files with 94 additions and 17 deletions
|
|
@ -287,6 +287,8 @@ class EmbedTokenClient(BaseDBClient):
|
|||
Returns:
|
||||
Dictionary with usage statistics
|
||||
"""
|
||||
from sqlalchemy import func
|
||||
|
||||
async with self.async_session() as session:
|
||||
# Get the token
|
||||
result = await session.execute(
|
||||
|
|
@ -302,16 +304,16 @@ class EmbedTokenClient(BaseDBClient):
|
|||
if not token:
|
||||
return {}
|
||||
|
||||
# Count active sessions
|
||||
# Count active sessions using SQL COUNT
|
||||
active_sessions_result = await session.execute(
|
||||
select(EmbedSessionModel).where(
|
||||
select(func.count(EmbedSessionModel.id)).where(
|
||||
and_(
|
||||
EmbedSessionModel.embed_token_id == token_id,
|
||||
EmbedSessionModel.expires_at > datetime.now(UTC),
|
||||
)
|
||||
)
|
||||
)
|
||||
active_sessions = len(active_sessions_result.scalars().all())
|
||||
active_sessions = active_sessions_result.scalar() or 0
|
||||
|
||||
return {
|
||||
"token_id": token_id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue