mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-24 04:43:24 +08:00
Run `ruff check app tests scripts --fix` with the configured rule set (E4/E7/E9/F/I): import sorting (I001), f-strings without placeholders (F541), lambda/variable/unused-import cleanups that ruff marks safe. Nine files whose only ruff debt sits next to pre-existing pylint import-resolution errors (lazy exports, sys.path script imports) or whose "unused" imports are reached through attribute access by tests are left untouched so the changed-file pylint gate and the benchmark tests stay green; their diagnostics remain in the baseline. app/startup/lifecycle/__init__.py and app/main.py import business modules after cache composition, import-path and stdio setup on purpose (the source comments document the contract), so declare E402 per-file-ignores for them instead of adding per-line noqa. Ruff ratchet watermark drops from 498 to 100; sync the baseline fixture and the optimization checklist figure. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from typing import Optional
|
|
|
|
from sqlalchemy import String, select
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from sqlalchemy.orm import Mapped, Session, mapped_column
|
|
|
|
from app.db.base import Base, get_id_column
|
|
|
|
|
|
class SiteIcon(Base):
|
|
"""
|
|
站点图标表
|
|
"""
|
|
id = get_id_column()
|
|
# 站点名称
|
|
name: Mapped[str] = mapped_column(String, nullable=False)
|
|
# 域名Key
|
|
domain: Mapped[Optional[str]] = mapped_column(String, index=True)
|
|
# 图标地址
|
|
url: Mapped[str] = mapped_column(String, nullable=False)
|
|
# 图标Base64
|
|
base64: Mapped[Optional[str]] = mapped_column(String)
|
|
|
|
@classmethod
|
|
def get_by_domain(cls, db: Session, domain: str):
|
|
"""在调用方 Session 中查询站点图标。"""
|
|
return db.execute(select(cls).where(cls.domain == domain)).scalars().first()
|
|
|
|
@classmethod
|
|
async def async_get_by_domain(
|
|
cls,
|
|
db: AsyncSession,
|
|
domain: str,
|
|
):
|
|
"""在调用方 AsyncSession 中查询站点图标。"""
|
|
result = await db.execute(select(cls).where(cls.domain == domain))
|
|
return result.scalar_one_or_none()
|