You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
705 B
22 lines
705 B
"""Утилиты по цепочке теста (попытки/версии).""" |
|
from __future__ import annotations |
|
|
|
from sqlalchemy import text |
|
|
|
|
|
def has_any_attempt_for_test(conn, test_id: str) -> bool: |
|
"""`conn` может быть Connection или Engine — обе поддерживают .execute().""" |
|
row = conn.execute( |
|
text( |
|
""" |
|
SELECT EXISTS ( |
|
SELECT 1 |
|
FROM test_attempts ta |
|
INNER JOIN test_versions tv ON ta.test_version_id = tv.id |
|
WHERE tv.test_id = :test_id |
|
) AS has_any |
|
""" |
|
), |
|
{'test_id': test_id}, |
|
).first() |
|
return bool(row[0])
|
|
|