Files
remnawave-bedolaga-telegram…/app/database/crud/squad.py
c0mrade 9a2aea038a chore: add uv package manager and ruff linter configuration
- Add pyproject.toml with uv and ruff configuration
- Pin Python version to 3.13 via .python-version
- Add Makefile commands: lint, format, fix
- Apply ruff formatting to entire codebase
- Remove unused imports (base64 in yookassa/simple_subscription)
- Update .gitignore for new config files
2026-01-24 17:45:27 +03:00

44 lines
1.2 KiB
Python

import logging
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.database.models import Squad
logger = logging.getLogger(__name__)
async def get_squad_by_uuid(db: AsyncSession, uuid: str) -> Squad | None:
result = await db.execute(select(Squad).where(Squad.uuid == uuid))
return result.scalar_one_or_none()
async def get_available_squads(db: AsyncSession) -> list[Squad]:
result = await db.execute(select(Squad).where(Squad.is_available == True))
return result.scalars().all()
async def create_squad(
db: AsyncSession, uuid: str, name: str, country_code: str = None, price_kopeks: int = 0, description: str = None
) -> Squad:
squad = Squad(uuid=uuid, name=name, country_code=country_code, price_kopeks=price_kopeks, description=description)
db.add(squad)
await db.commit()
await db.refresh(squad)
logger.info(f'✅ Создан сквад: {name}')
return squad
async def update_squad(db: AsyncSession, squad: Squad, **kwargs) -> Squad:
for field, value in kwargs.items():
if hasattr(squad, field):
setattr(squad, field, value)
await db.commit()
await db.refresh(squad)
return squad