Skip to content

New fitch4#5

Open
olred wants to merge 6 commits intodev2from
new_fitch4
Open

New fitch4#5
olred wants to merge 6 commits intodev2from
new_fitch4

Conversation

@olred
Copy link
Owner

@olred olred commented Mar 7, 2023

Изменения после ревью.



def run():
loop = asyncio.get_event_loop()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

посмотри новый синтакс юез лупа


async def stop(self):
await self.out_queue.join()
for t in self._tasks:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uploading image.png…
всегда пусто же получается

self.out_queue.task_done()

async def start(self):
asyncio.create_task(self._worker())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ты не положил таску никуда

Comment on lines +24 to +26
chat_id=upd[1],
attachment=upd[3],
text=upd[2],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше структурку для такого сделать с тайпингами

Comment on lines +21 to +31
def check_kicked(kicked_users: list, active_users: dict):
i = 0
while i != len(active_users["participants"]):
if list(active_users["participants"][i].keys())[-1] in kicked_users:
active_users["participants"] = (
active_users["participants"][:i]
+ active_users["participants"][i + 1 :]
)
else:
i += 1
return active_users

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как то очень неудобно выглядит

Comment on lines +16 to +25
state_photo = Column(Boolean)
state_in_game = Column(Boolean)
state_wait_votes = Column(Boolean)
new_pair = Column(JSONB)
first_votes = Column(BigInteger, default=0)
second_votes = Column(BigInteger, default=0)
state_send_photo = Column(Boolean)
voters = Column(JSONB)
amount_users = Column(BigInteger)
last_winner = Column(Text)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не нужно кучу флагов плодить

можно просто строковый стейт сделать и он тогда в 1 поле будет
иначе мб такое, что больше 1 флага тру

Comment on lines +40 to +42
chat_id = Column(
BigInteger, ForeignKey("game_session.chat_id", ondelete="CASCADE")
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут игровая сессия должна быть, а не чат

await self.disconnect(app)

async def make_userlist(self, chat_id):
async def make_userlist(self, chat_id, app):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тайпингов везде сильно не хватает

прогнать бы через mypy

async def stop(self):
self.is_running = False
await self.poll_task
self.poll_task.cancel()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не правильно отменяешь таску, посмотри пример в доке, там еще подождать конца отмены нужно

@@ -0,0 +1,113 @@
import logging

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

фикстуры лучше по разным файлам раскидать в зависимости от того, какие сущности используются

Comment on lines +243 to +273
await store.bot_manager.handle_updates(
Update(
type="message_new",
object=UpdateObject(
id=1,
chat_id=1,
body="Загрузить фотографии!",
type="test_type",
),
)
)
await store.bot_manager.handle_updates(
Update(
type="message_new",
object=UpdateObject(
id=1, chat_id=1, body="Начать игру!", type="test_type"
),
)
)
await store.bot_manager.handle_updates(
Update(
type="message_new",
object=UpdateObject(
id=1,
chat_id=1,
body="Моя статистика!",
type="test_type",
),
)
)
await store.bot_manager.handle_updates(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для такого есть @pytest.parametrize()

Comment on lines +223 to +234
async with db_session.begin() as session:
for i in range(2):
new_user = ParticipantsModel(
name=f"olred{i}",
wins=0,
chat_id=1,
owner_id=1 + i,
photo_id=1,
access_key="dasda",
)
session.add(new_user)
await session.commit()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

такие вещи должны быть в фикстурах

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants