"""Platform-setting-backed configuration for the attendance domain. Everything operationally tunable (which department counts as interns, the cycle start day, reminder behaviour) lives in ``platform_settings`` so IT can change it without a deploy. These helpers centralise the defaulting + coercion so callers never see a malformed setting. """ from __future__ import annotations from sqlalchemy.ext.asyncio import AsyncSession from app.domains.attendance import constants as c from app.integrations.service import get_platform_setting async def get_intern_department(db: AsyncSession) -> str: val = await get_platform_setting( c.SETTING_INTERN_DEPARTMENT, c.DEFAULT_INTERN_DEPARTMENT, session=db, ) name = str(val).strip() if val is not None else "" return name or c.DEFAULT_INTERN_DEPARTMENT async def get_cycle_start_day(db: AsyncSession) -> int: val = await get_platform_setting( c.SETTING_CYCLE_START_DAY, c.DEFAULT_CYCLE_START_DAY, session=db, ) try: day = int(val) except (TypeError, ValueError): return c.DEFAULT_CYCLE_START_DAY return day if 1 <= day <= 28 else c.DEFAULT_CYCLE_START_DAY