Files
rengine/worker/app/database.py
T
Yogesh OjhaandClaude Fable 5.1 d4072b8efa perf: make the read path scale with the estate
Scan page froze on a duplicate each key; every tab body now sits in a
svelte:boundary. Composite discovered_at indexes on the five result
tables, leads counted in one FILTER pass, dashboard and scan-service
first-seen counts bounded to the scans in the window, ANALYZE at
finalize, shm_size on the db service, SQL_ECHO instead of DEBUG, an
entrypoint that serves with workers outside reload.

Settled-scope aggregates and search pages are cached by target
revision; triage, dismissal, interest evaluation, notes, certificate
rechecks and re-ranking bump it. Requests per page cut: single-flight
GETs, one schemas endpoint, batched whois correlations, a counts
endpoint for the dashboard, deduped store loads, trimmed coverage
payloads.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NWRq8utu7KXsVBVU3gYNi7
2026-09-12 08:49:41 +05:30

28 lines
699 B
Python

"""Sync database session for Celery workers."""
from sqlalchemy import create_engine
from sqlalchemy.orm import Session, sessionmaker
from app.config import settings
engine = create_engine(
settings.database_url,
echo=settings.SQL_ECHO,
pool_pre_ping=True,
pool_size=settings.WORKER_DB_POOL_SIZE,
max_overflow=settings.WORKER_DB_MAX_OVERFLOW,
pool_timeout=settings.WORKER_DB_POOL_TIMEOUT,
pool_recycle=settings.DB_POOL_RECYCLE,
connect_args={"application_name": f"{settings.APP_NAME}-worker"},
)
SyncSessionLocal = sessionmaker(
bind=engine,
class_=Session,
expire_on_commit=False,
)
def get_sync_session() -> Session:
return SyncSessionLocal()