Persistent Browser Session Uptime cost metering/credit consumption + Posthog flags for billing v2 (#4444)
This commit is contained in:
31
alembic/versions/2026_01_15_0713-a720c991f779_add_index.py
Normal file
31
alembic/versions/2026_01_15_0713-a720c991f779_add_index.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
"""add index
|
||||||
|
|
||||||
|
Revision ID: a720c991f779
|
||||||
|
Revises: 18a4ed894511
|
||||||
|
Create Date: 2026-01-15 07:13:16.022412+00:00
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "a720c991f779"
|
||||||
|
down_revision: Union[str, None] = "18a4ed894511"
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_index(
|
||||||
|
op.f("ix_debug_sessions_browser_session_id"), "debug_sessions", ["browser_session_id"], unique=False
|
||||||
|
)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_index(op.f("ix_debug_sessions_browser_session_id"), table_name="debug_sessions")
|
||||||
|
# ### end Alembic commands ###
|
||||||
@@ -5271,6 +5271,21 @@ class AgentDB(BaseAlchemyDB):
|
|||||||
|
|
||||||
return DebugSession.model_validate(model) if model else None
|
return DebugSession.model_validate(model) if model else None
|
||||||
|
|
||||||
|
async def get_debug_session_by_browser_session_id(
|
||||||
|
self,
|
||||||
|
browser_session_id: str,
|
||||||
|
organization_id: str,
|
||||||
|
) -> DebugSession | None:
|
||||||
|
async with self.Session() as session:
|
||||||
|
query = (
|
||||||
|
select(DebugSessionModel)
|
||||||
|
.filter_by(browser_session_id=browser_session_id)
|
||||||
|
.filter_by(organization_id=organization_id)
|
||||||
|
.filter_by(deleted_at=None)
|
||||||
|
)
|
||||||
|
model = (await session.scalars(query)).first()
|
||||||
|
return DebugSession.model_validate(model) if model else None
|
||||||
|
|
||||||
async def get_workflow_runs_by_debug_session_id(
|
async def get_workflow_runs_by_debug_session_id(
|
||||||
self,
|
self,
|
||||||
debug_session_id: str,
|
debug_session_id: str,
|
||||||
|
|||||||
@@ -948,7 +948,7 @@ class DebugSessionModel(Base):
|
|||||||
|
|
||||||
debug_session_id = Column(String, primary_key=True, default=generate_debug_session_id)
|
debug_session_id = Column(String, primary_key=True, default=generate_debug_session_id)
|
||||||
organization_id = Column(String, nullable=False)
|
organization_id = Column(String, nullable=False)
|
||||||
browser_session_id = Column(String, nullable=False)
|
browser_session_id = Column(String, nullable=False, index=True)
|
||||||
vnc_streaming_supported = Column(Boolean, nullable=True, server_default=sqlalchemy.true())
|
vnc_streaming_supported = Column(Boolean, nullable=True, server_default=sqlalchemy.true())
|
||||||
workflow_permanent_id = Column(String, nullable=True)
|
workflow_permanent_id = Column(String, nullable=True)
|
||||||
user_id = Column(String, nullable=True) # comes from identity vendor (Clerk at time of writing)
|
user_id = Column(String, nullable=True) # comes from identity vendor (Clerk at time of writing)
|
||||||
|
|||||||
Reference in New Issue
Block a user