Skip to content

New fitch4#5

Open
olred wants to merge 6 commits into
dev2from
new_fitch4
Open

New fitch4#5
olred wants to merge 6 commits into
dev2from
new_fitch4

Conversation

@olred

@olred olred commented Mar 7, 2023

Copy link
Copy Markdown
Owner

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



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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread app/store/bot/sender.py

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread app/store/bot/sender.py
self.out_queue.task_done()

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread app/store/bot/sender.py
Comment on lines +24 to +26
chat_id=upd[1],
attachment=upd[3],
text=upd[2],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread app/store/bot/services.py
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread app/store/models/model.py
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

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

Comment thread app/store/models/model.py
Comment on lines +40 to +42
chat_id = Column(
BigInteger, ForeignKey("game_session.chat_id", ondelete="CASCADE")
)

Copy link
Copy Markdown

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):

Copy link
Copy Markdown

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread tests/fixtures/common.py
@@ -0,0 +1,113 @@
import logging

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread tests/bot/test_bot.py
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(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread tests/bot/test_bot.py
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()

Copy link
Copy Markdown

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