diff --git a/apps/py-categories-service/main.py b/apps/py-categories-service/main.py index e69de29..ddb4111 100644 --- a/apps/py-categories-service/main.py +++ b/apps/py-categories-service/main.py @@ -0,0 +1,15 @@ +import asyncio +from websockets.server import serve + + +async def handler(websocket): + async for message in websocket: + print('recv msg', message) + # await websocket.recv(message) + + +async def main(): + async with serve(handler, '0.0.0.0', 8765): + await asyncio.Future() # run forever + +asyncio.run(main()) diff --git a/apps/py-categories-service/requirements.txt b/apps/py-categories-service/requirements.txt index e69de29..14774b4 100644 --- a/apps/py-categories-service/requirements.txt +++ b/apps/py-categories-service/requirements.txt @@ -0,0 +1 @@ +websockets diff --git a/apps/py-conveyor-service/api/response/analytics.py b/apps/py-conveyor-service/api/response/analytics.py index 7a1bf17..27bb64d 100644 --- a/apps/py-conveyor-service/api/response/analytics.py +++ b/apps/py-conveyor-service/api/response/analytics.py @@ -63,6 +63,7 @@ class ResponseAnalyticsFactory: @classmethod def get_from_model_timeline_chart(cls, models: list[DBConveer]) -> list[TimelineCharts]: response = [] + print(len(models)) for i in models: response.append(cls.get_from_model_timeline_charts(name='wood', value=i.wood, time=i.created_at)) response.append(cls.get_from_model_timeline_charts(name='glass', value=i.glass, time=i.created_at)) diff --git a/apps/py-conveyor-service/db/migrations/versions/3c651a0d1fe0_initial.py b/apps/py-conveyor-service/db/migrations/versions/3c651a0d1fe0_initial.py index 932d123..25b0a8d 100644 --- a/apps/py-conveyor-service/db/migrations/versions/3c651a0d1fe0_initial.py +++ b/apps/py-conveyor-service/db/migrations/versions/3c651a0d1fe0_initial.py @@ -7,6 +7,7 @@ Create Date: 2023-10-27 18:19:47.402501 """ import random import time +from datetime import datetime, timedelta from alembic import op import sqlalchemy as sa @@ -49,9 +50,13 @@ def upgrade(): ) op.execute('''INSERT INTO camera(id,order_numb, camera_type) VALUES (1,1, 'По умолчанию')''') for i in range(0, 12): - op.execute('''INSERT INTO conveer (metal, glass, plastic, wood, camera_id) VALUES (floor(random() * 20 + 1), - floor(random() * 10 + 1), floor(random() * 15 + 1), floor(random() * 30 + 1), 1);''') - time.sleep(random.randint(0, 3)) + import random + from datetime import datetime, timedelta + + for _ in range(0, 100): + random_date = datetime.now() - timedelta(days=random.randint(1, 365)) # Генерация случайной даты за последний год + op.execute(f'''INSERT INTO conveer (metal, glass, plastic, wood, camera_id, created_at) + VALUES (floor(random() * 20 + 1), floor(random() * 10 + 1), floor(random() * 15 + 1), floor(random() * 30 + 1), 1,'{random_date}');''') def downgrade():