main
Nikita 1 year ago
parent 96b4fed18c
commit 16a05a4a31

@ -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())

@ -63,6 +63,7 @@ class ResponseAnalyticsFactory:
@classmethod @classmethod
def get_from_model_timeline_chart(cls, models: list[DBConveer]) -> list[TimelineCharts]: def get_from_model_timeline_chart(cls, models: list[DBConveer]) -> list[TimelineCharts]:
response = [] response = []
print(len(models))
for i in 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='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)) response.append(cls.get_from_model_timeline_charts(name='glass', value=i.glass, time=i.created_at))

@ -7,6 +7,7 @@ Create Date: 2023-10-27 18:19:47.402501
""" """
import random import random
import time import time
from datetime import datetime, timedelta
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
@ -49,9 +50,13 @@ def upgrade():
) )
op.execute('''INSERT INTO camera(id,order_numb, camera_type) VALUES (1,1, 'По умолчанию')''') op.execute('''INSERT INTO camera(id,order_numb, camera_type) VALUES (1,1, 'По умолчанию')''')
for i in range(0, 12): for i in range(0, 12):
op.execute('''INSERT INTO conveer (metal, glass, plastic, wood, camera_id) VALUES (floor(random() * 20 + 1), import random
floor(random() * 10 + 1), floor(random() * 15 + 1), floor(random() * 30 + 1), 1);''') from datetime import datetime, timedelta
time.sleep(random.randint(0, 3))
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(): def downgrade():

Loading…
Cancel
Save