Spaces:
Running on T4
Running on T4
Download backend/app/common/consent.py from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 757 Bytes
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/app/common/consent.py
- Command line
-
hf download hf://spaces/modventures/baseball-engine/backend/app/common/consent.py
-
curl -L -o consent.py https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/app/common/consent.py
757 Bytes
| """Whether the player's analysis consent allows running an analysis.""" | |
| from uuid import UUID | |
| from sqlalchemy import select | |
| from sqlalchemy.ext.asyncio import AsyncSession | |
| from app.modules.settings.models import ConsentEvent | |
| async def analysis_consent_blocked(db: AsyncSession, account_id: UUID, require_accepted: bool) -> bool: | |
| """True when the latest analysis consent is a withdrawal, or (when required) there is no acceptance.""" | |
| action = await db.scalar( | |
| select(ConsentEvent.action) | |
| .where(ConsentEvent.account_id == account_id, ConsentEvent.category == "analysis") | |
| .order_by(ConsentEvent.created_at.desc(), ConsentEvent.id.desc()).limit(1)) | |
| return action == "withdrawn" or (require_accepted and action is None) | |