"""The account filter the activity page's lists share (runs, admin actions, server log, quota): one filter bar drives them all, so the value it sends means the same on every tab. The value is an account id, or `none` — the rows no account made (the background) — a value to filter on, not the absence of a filter. """ from sqlalchemy import ColumnElement NONE = "none" # The `user` query parameter's shape on every route that takes it. PATTERN = r"^(none|[0-9]{1,10})$" def condition(column, value: str) -> ColumnElement[bool]: """`column` (an account id column) narrowed to `value`.""" return column.is_(None) if value == NONE else column == int(value)