refactor: reorganize startup persistence boundaries

This commit is contained in:
jxxghp
2026-08-23 21:24:34 +08:00
parent 7f09927c47
commit e1509c4e0d
96 changed files with 1036 additions and 782 deletions
+3 -4
View File
@@ -4,7 +4,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Mapped, Session, mapped_column
from app.db.base import Base, get_id_column
from app.db.decorators import run_legacy_async_query
from app.db.decorators import legacy_async_db_query
class SiteIcon(Base):
@@ -27,6 +27,7 @@ class SiteIcon(Base):
return db.execute(select(cls).where(cls.domain == domain)).scalars().first()
@classmethod
@legacy_async_db_query
async def async_get_by_domain(
cls,
db: AsyncSession | None = None,
@@ -41,6 +42,4 @@ class SiteIcon(Base):
result = await session.execute(select(cls).where(cls.domain == domain))
return result.scalar_one_or_none()
if isinstance(db, AsyncSession):
return await query(db)
return await run_legacy_async_query(query)
return await query(db)