2024-10-28 13:30:02 +04:00
|
|
|
from typing import Sequence
|
2024-10-27 23:29:52 +04:00
|
|
|
|
2024-10-25 02:02:31 +04:00
|
|
|
from sqlalchemy.future import select
|
2024-10-27 23:29:52 +04:00
|
|
|
|
2024-10-14 21:18:07 +04:00
|
|
|
from db.models.experiment_data_model import ExperimentData
|
2024-10-28 13:30:02 +04:00
|
|
|
from db.postgres_db_connection import async_session_postgres
|
2024-10-27 23:29:52 +04:00
|
|
|
|
|
|
|
|
2024-10-28 13:30:02 +04:00
|
|
|
async def get_exp_data_by_file_id(file_id: str) -> Sequence[ExperimentData]:
|
|
|
|
async with async_session_postgres() as session:
|
|
|
|
result = await session.execute(
|
|
|
|
select(ExperimentData).where(ExperimentData.file_id == file_id)
|
2024-10-22 16:46:39 +04:00
|
|
|
)
|
2024-10-28 13:30:02 +04:00
|
|
|
return result.scalars().all()
|
2024-10-28 13:55:17 +04:00
|
|
|
|
|
|
|
|
|
|
|
async def get_all_exp_data(page: int, page_size: int) -> Sequence[ExperimentData]:
|
|
|
|
async with async_session_postgres() as session:
|
|
|
|
offset = (page - 1) * page_size
|
|
|
|
|
|
|
|
result = await session.execute(
|
|
|
|
select(ExperimentData).offset(offset).limit(page_size)
|
|
|
|
)
|
|
|
|
return result.scalars().all()
|