From fe33d5c7f6f46b792b2e20c6098d7c8dad28c63d Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Fri, 18 Jul 2025 09:55:22 +0300 Subject: [PATCH] [+] rename module folder 1. rename python module folder; 2. clean up payloads/logic.py; 3. update partially payloads/alembic/env.py; --- .../test_task_2025_07_17_v1/payloads/logic.py | 83 ------------------ .../__init__.py | 0 .../async_api/__init__.py | 0 .../async_api/app.py | 0 .../async_api/db.py | 0 .../async_api/fastapi.py | 0 .../async_api/schema.py | 0 .../async_api/settings.py | 0 .../async_api/websocket_api.py | 0 .../payloads/__init__.py | 0 .../payloads/alembic/env.py | 6 +- .../payloads/alembic/script.py.mako | 0 .../test_task_2025_07_17_v2/payloads/logic.py | 84 +++++++++++++++++++ .../payloads/models.py | 0 .../payloads/settings.py | 0 .../payloads/utils.py | 0 .../py.typed | 0 17 files changed, 87 insertions(+), 86 deletions(-) delete mode 100644 deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/logic.py rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/__init__.py (100%) rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/async_api/__init__.py (100%) rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/async_api/app.py (100%) rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/async_api/db.py (100%) rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/async_api/fastapi.py (100%) rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/async_api/schema.py (100%) rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/async_api/settings.py (100%) rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/async_api/websocket_api.py (100%) rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/payloads/__init__.py (100%) rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/payloads/alembic/env.py (94%) rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/payloads/alembic/script.py.mako (100%) create mode 100644 deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/logic.py rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/payloads/models.py (100%) rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/payloads/settings.py (100%) rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/payloads/utils.py (100%) rename deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/{test_task_2025_07_17_v1 => test_task_2025_07_17_v2}/py.typed (100%) diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/logic.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/logic.py deleted file mode 100644 index 164a4d8..0000000 --- a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/logic.py +++ /dev/null @@ -1,83 +0,0 @@ -import datetime - -from sqlalchemy.ext.asyncio import AsyncSession -from sqlalchemy.ext.asyncio import async_sessionmaker -from sqlalchemy.orm import selectinload, make_transient -from sqlalchemy.future import select - -from .models import Ticker, Market -from .utils import get_or_create - -async def markets_get_by_symbol( - session: 'async_sessionmaker[AsyncSession]', - symbols: set[str], -) -> dict[str, int]: - res : dict[str, int] = dict() - - async with session() as active_session: - async with active_session.begin() as transaction: - for o in symbols: - m = (await get_or_create( - active_session, - Market, - name=o, - ))[0] - res[o] = m.id - - return res - -async def ticker_store_multiple( - session: 'async_sessionmaker[AsyncSession]', - tickers: list[Ticker], -) -> None: - async with session() as active_session: - async with active_session.begin() as transaction: - active_session.add_all( - tickers, - ) - -async def tickers_get_by_period( - session: 'async_sessionmaker[AsyncSession]', - market_id: int, - period: datetime.timedelta, -) -> list[Ticker]: - async with session() as active_session: - async with active_session.begin() as transaction: - q = select( - Ticker - ).join(Ticker.market).where( - Market.id == market_id, - Ticker.timestamp >= datetime.datetime.now( - tz=datetime.timezone.utc - ) - period - ).order_by(Ticker.timestamp.desc()).options( - selectinload(Ticker.market) - ) - - res = await active_session.execute(q) - - rows = [o[0] for o in res] - - for o in rows: - active_session.expunge(o) - make_transient(o.market) - - return rows - -async def markets_all( - session: 'async_sessionmaker[AsyncSession]', -) -> list[Market]: - async with session() as active_session: - async with active_session.begin() as transaction: - q = select( - Market - ) - - res = await active_session.execute(q) - - rows = [o[0] for o in res] - - for o in rows: - active_session.expunge(o) - - return rows diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/__init__.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/__init__.py similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/__init__.py rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/__init__.py diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/__init__.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/__init__.py similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/__init__.py rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/__init__.py diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/app.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/app.py similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/app.py rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/app.py diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/db.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/db.py similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/db.py rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/db.py diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/fastapi.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/fastapi.py similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/fastapi.py rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/fastapi.py diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/schema.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/schema.py similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/schema.py rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/schema.py diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/settings.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/settings.py similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/settings.py rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/settings.py diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/websocket_api.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/websocket_api.py similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/async_api/websocket_api.py rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/async_api/websocket_api.py diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/__init__.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/__init__.py similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/__init__.py rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/__init__.py diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/alembic/env.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/alembic/env.py similarity index 94% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/alembic/env.py rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/alembic/env.py index 19db939..c63c2be 100644 --- a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/alembic/env.py +++ b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/alembic/env.py @@ -12,10 +12,10 @@ from sqlalchemy.engine.base import Connection from alembic import context -from online.fxreader.pr34.test_task_2025_06_30_v1.tickers.settings import Settings -from online.fxreader.pr34.test_task_2025_06_30_v1.tickers.models import ( +from online.fxreader.pr34.test_task_2025_07_17_v2.payloads.settings import Settings +from online.fxreader.pr34.test_task_2025_07_17_v2.payloads.models import ( Base, - Market, + # Market, ) # this is the Alembic Config object, which provides diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/alembic/script.py.mako b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/alembic/script.py.mako similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/alembic/script.py.mako rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/alembic/script.py.mako diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/logic.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/logic.py new file mode 100644 index 0000000..d65f829 --- /dev/null +++ b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/logic.py @@ -0,0 +1,84 @@ +import datetime + +from sqlalchemy.ext.asyncio import AsyncSession +from sqlalchemy.ext.asyncio import async_sessionmaker +from sqlalchemy.orm import selectinload, make_transient +from sqlalchemy.future import select + +from .models import Payload +from .utils import get_or_create + +# async def markets_get_by_symbol( +# session: 'async_sessionmaker[AsyncSession]', +# symbols: set[str], +# ) -> dict[str, int]: +# res : dict[str, int] = dict() +# +# async with session() as active_session: +# async with active_session.begin() as transaction: +# for o in symbols: +# m = (await get_or_create( +# active_session, +# Market, +# name=o, +# ))[0] +# res[o] = m.id +# +# return res +# +# async def ticker_store_multiple( +# session: 'async_sessionmaker[AsyncSession]', +# tickers: list[Ticker], +# ) -> None: +# async with session() as active_session: +# async with active_session.begin() as transaction: +# active_session.add_all( +# tickers, +# ) +# +# async def tickers_get_by_period( +# session: 'async_sessionmaker[AsyncSession]', +# market_id: int, +# period: datetime.timedelta, +# ) -> list[Ticker]: +# async with session() as active_session: +# async with active_session.begin() as transaction: +# q = select( +# Ticker +# ).join(Ticker.market).where( +# Market.id == market_id, +# Ticker.timestamp >= datetime.datetime.now( +# tz=datetime.timezone.utc +# ) - period +# ).order_by(Ticker.timestamp.desc()).options( +# selectinload(Ticker.market) +# ) +# +# res = await active_session.execute(q) +# +# rows = [o[0] for o in res] +# +# for o in rows: +# active_session.expunge(o) +# make_transient(o.market) +# +# return rows +# +# async def markets_all( +# session: 'async_sessionmaker[AsyncSession]', +# ) -> list[Market]: +# async with session() as active_session: +# async with active_session.begin() as transaction: +# q = select( +# Market +# ) +# +# res = await active_session.execute(q) +# +# rows = [o[0] for o in res] +# +# for o in rows: +# active_session.expunge(o) +# +# return rows +# diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/models.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/models.py similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/models.py rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/models.py diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/settings.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/settings.py similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/settings.py rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/settings.py diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/utils.py b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/utils.py similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/payloads/utils.py rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/payloads/utils.py diff --git a/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/py.typed b/deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/py.typed similarity index 100% rename from deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v1/py.typed rename to deps/test-task-2025-07-17-v2/python/online/fxreader/pr34/test_task_2025_07_17_v2/py.typed